Need info about listeners for new Buttons

Discussion about Mods for Prison Architect

Moderator: NBJeff

User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Need info about listeners for new Buttons

Postby Brento666 » Sat Dec 19, 2015 1:49 am

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!
JonyBlaze
level0
Posts: 2
Joined: Tue Dec 15, 2015 2:46 am

Re: Need info about listeners for new Buttons

Postby JonyBlaze » Sat Dec 19, 2015 5:39 am

Goood :D
Linkero
level0
Posts: 2
Joined: Sun Dec 20, 2015 12:49 am

Re: Need info about listeners for new Buttons

Postby Linkero » Sun Dec 20, 2015 7:15 pm

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!!!!!!
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: Need info about listeners for new Buttons

Postby elDiablo » Sun Dec 20, 2015 7:32 pm

Yeah, sorry about that everyone. We intended to give out the example mods with the update. My bad! Well done on figuring it out!
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Need info about listeners for new Buttons

Postby Brento666 » Sun Dec 20, 2015 10:36 pm

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)
CoffeeBalls21
level0
Posts: 9
Joined: Sun Feb 10, 2013 10:31 pm
Location: United Kingdom

Re: Need info about listeners for new Buttons

Postby CoffeeBalls21 » Sat Mar 05, 2016 8:01 pm

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"
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: Need info about listeners for new Buttons

Postby elDiablo » Mon Mar 07, 2016 9:33 am

Currently none, but it gives us the ability to expand in future if people want other things.
CoffeeBalls21
level0
Posts: 9
Joined: Sun Feb 10, 2013 10:31 pm
Location: United Kingdom

Re: Need info about listeners for new Buttons

Postby CoffeeBalls21 » Wed Mar 09, 2016 6:35 pm

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
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: Need info about listeners for new Buttons

Postby elDiablo » Fri Mar 11, 2016 12:40 pm

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.
murgh
level2
level2
Posts: 232
Joined: Sat Jan 30, 2016 11:52 am

Re: Need info about listeners for new Buttons

Postby murgh » Fri Aug 05, 2016 9:49 am

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.

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 2 guests