Page 1 of 1

Need info about listeners for new Buttons

Posted: Sat Dec 19, 2015 1:49 am
by Brento666
Hi hi!
I'm having no luck figuring out the syntax for listeners to the new buttons, so I can't handle the click-events atm... I've tried some obvious forms like;

Code: Select all

function JobComplete_PlaceExplosiveCharge()
    this.SubType = 1
   this.AddInterfaceComponent("ManualBtn", "Button", "Manual Detonation")
end


function InterfaceComponent_ManualBtn()--no
    Echo("Click!")
end

function InterfaceComponent_Button()--no
    Echo("Click!")
end

function InterfaceComponent_Click()--no
    Echo("Click!")
end

function Click_Button()--no
    Echo("Click!")
end

function Click_ManualBtn()--no
    Echo("Click!")
end

function Click_InterfaceComponent()--no
    Echo("Click!")
end

function InterfaceComponent_Click_ManualBtn()--no
    Echo("Click!")
end

function InterfaceComponent_ManualBtn_Click()--no
    Echo("Click!")
end

function Click_InterfaceComponent_Button()--no
    Echo("Click!")
end

function Click_InterfaceComponent_ManualBtn()--no
    Echo("Click!")
end

function Click_Button_InterfaceComponent()--no
    Echo("Click!")
end

function Click_ManualBtn_InterfaceComponent()--no
    Echo("Click!")
end

function ManualBtn()--no
    Echo("Click!")
end

function ManualBtn_Button()-no
    Echo("Click!")
end

function Button_ManualBtn()-no
    Echo("Click!")
end

-don't worry I didn't test each one separately :mrgreen:

So I need some help pinpointing the form for listeners to the new btns!!

I'd go check the mod mentioned in the update, but that isn't in the workshop yet...
Muchos gracias!

Re: Need info about listeners for new Buttons

Posted: Sat Dec 19, 2015 5:39 am
by JonyBlaze
Goood :D

Re: Need info about listeners for new Buttons

Posted: Sun Dec 20, 2015 7:15 pm
by Linkero

Code: Select all


this.AddInterfaceComponent( "ButtonName", "Button", "Test Button")

function ButtonNameClicked()
   Game.DebugOut("Button Clicked")
end



Damn this one killed me :| About 125 combo's I tried till I got it. Let the fun begin!!!!!!

Re: Need info about listeners for new Buttons

Posted: Sun Dec 20, 2015 7:32 pm
by elDiablo
Yeah, sorry about that everyone. We intended to give out the example mods with the update. My bad! Well done on figuring it out!

Re: Need info about listeners for new Buttons

Posted: Sun Dec 20, 2015 10:36 pm
by Brento666
Linkero wrote:Damn this one killed me :| About 125 combo's I tried till I got it. Let the fun begin!!!!!!

Well done and thanks! I thought I would get it with my tries.. but after 20 odd (all with an expected underscore) I called it quits!! :mrgreen:

@elDiablo: No worries, had plenty to play with :D

-One thing I did find is that atm buttons are not persistent; so after load you need to set them up again(!)
(not a huge deal, a simple local boolean helps me determine if my "init()" needs to run again)

Re: Need info about listeners for new Buttons

Posted: Sat Mar 05, 2016 8:01 pm
by CoffeeBalls21
elDiablo wrote:Yeah, sorry about that everyone. We intended to give out the example mods with the update. My bad! Well done on figuring it out!


Can I ask what other arguments can be used for the Interface Type other than "Button"

Re: Need info about listeners for new Buttons

Posted: Mon Mar 07, 2016 9:33 am
by elDiablo
Currently none, but it gives us the ability to expand in future if people want other things.

Re: Need info about listeners for new Buttons

Posted: Wed Mar 09, 2016 6:35 pm
by CoffeeBalls21
elDiablo wrote:Currently none, but it gives us the ability to expand in future if people want other things.


Thanks elDiablo,

Is there a dedicated place were Modders can request features for future versions?

This is my mod below and it works as it is but there is a lot more I would like to do with it given access to the right functions and data.
http://steamcommunity.com/sharedfiles/f ... =384096586

Kind Regards

Re: Need info about listeners for new Buttons

Posted: Fri Mar 11, 2016 12:40 pm
by elDiablo
Putting a topic up on the Mantis bug tracker (for example, "add an input slider to the mod interface list" or something), and getting people to vote for it is probably the best way. Though I can't confirm if/when stuff will be added, I'm afraid.

Re: Need info about listeners for new Buttons

Posted: Fri Aug 05, 2016 9:49 am
by murgh
Bumping this topic with a bit more info on the buttons (thanks to elDiablo!):

You can put flags into your interface buttons and captions in the same way other language strings work. If you have a language string file that contains

Code: Select all

my_language_string            This is *X string
my_language_string_my         my


In the lua code you can do any of the following:

Code: Select all

- Interface.AddComponent( "MyButton", "Button", "my_language_string", "my_language_string_my", "X" )                  -- Caption is set to "This is my string"
- Interface.AddComponent( "MyButton", "Button", "my_language_string", "your", "X" )                                 -- Caption is set to "This is your string"
- Interface.AddComponent( "MyButton", "Button", "my_language_string", 4, "X" )                                       -- Caption is set to "This is 4 string"


You can also include multiple flags in the same string

Code: Select all

my_other_string          This is *X other *Y

for example.