I have a question, what calls makeControls(caller, control, base, size, space, omit) if I want the buttons or things like that to appear somewhere? Could you provide a quick short installation guide please ?
Script: Make Multiple Buttons/Levers
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Script: Make Multiple Buttons/Levers
Great Scripting Lark, thanks a lot 
I have a question, what calls makeControls(caller, control, base, size, space, omit) if I want the buttons or things like that to appear somewhere? Could you provide a quick short installation guide please ?
I have a question, what calls makeControls(caller, control, base, size, space, omit) if I want the buttons or things like that to appear somewhere? Could you provide a quick short installation guide please ?
A trip of a thousand leagues starts with a step.
Re: Script: Make Multiple Buttons/Levers
Sorry I wasn't clear on that - here's what you do:
Does this answer your questions? Take care, -Lark
- Create a LUA script entity in the square that is to have the buttons/levers. Let's say buttons for the examples. The buttons will appear in the same square as the LUA script. The wall on which the buttons appear will depend upon which direction the script is facing.
- Three functions and one initialization call were included in the original example.
- makeControls - actually places the controls
- buttonPress - gets called when any button is pressed; button ID is passed as a parameter
- leverFlip - gets called when any lever is flipped; lever ID is passed as a parameter
- The buttons are actually created by the last line in the script: makeControls(self, "wall_button", self.go.id .."_button_", {3, 3}, {.4, -.4, .4, -.4}, {21, 23, 12, 32}) is one included example.
Does this answer your questions? Take care, -Lark
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Script: Make Multiple Buttons/Levers
You sure did. This is amazing, and so helpfull. Hello, crafting station 
Thank you so much for sharing
Oh, and I credited you oc
Thank you so much for sharing
Oh, and I credited you oc
A trip of a thousand leagues starts with a step.
Re: Script: Make Multiple Buttons/Levers
Well, I am not very smart in scripting, so this is some kind of miracle for me, Lark.
I could get this running in my mod and I could alter the appearance. But I do not understand how to make the buttons to do something.
So - what I have are three buttons in a vertical row and I want button A to trigger script A, button B to trigger script B and so...
Can someone give me a clue how to script that?
I could get this running in my mod and I could alter the appearance. But I do not understand how to make the buttons to do something.
So - what I have are three buttons in a vertical row and I want button A to trigger script A, button B to trigger script B and so...
Can someone give me a clue how to script that?
Re: Script: Make Multiple Buttons/Levers
The function buttonPress() is where the button or lever's action originates. The variable *pressed* is a local numerical id derived for the button; use it to script a block in the buttonPress() function, that either contains or calls your scripted action for each button.THOM wrote:So - what I have are three buttons in a vertical row and I want button A to trigger script A, button B to trigger script B and so...
Can someone give me a clue how to script that?
Here is one method:
SpoilerShow
Replace Lark's buttonPress(), and the call to makeControls() [at the very end of the script] with these snippets. It will setup three [centered] buttons, and will call the function myFunc() in script_A, script_B, and script_C; which have to exist on the map.
Or... You can replace either or each *script_#.script.myFunc(pushed)* call with something like my_door_1.door:toggle() to have the button open and close the my_door object.
A simple template for script_A:
Or... You can replace either or each *script_#.script.myFunc(pushed)* call with something like my_door_1.door:toggle() to have the button open and close the my_door object.
Code: Select all
function buttonPress(my)
local pushed = tonumber(string.sub(my.go.id, string.len(my.go.id) - 1))
--=|--------------------------------------------------------------------------------------------------------
local buttonAction = { [12] = function() script_A.script.myFunc(pushed) end,
[22] = function() script_B.script.myFunc(pushed) end,
[32] = function() script_C.script.myFunc(pushed) end,
}
buttonAction[pushed]()
--=|--------------------------------------------------------------------------------------------------------
end
Code: Select all
--=|----place below leverFlip()------------------------------------------------------------------------------------
makeControls(self, "wall_button", self.go.id .."_button_", {3, 3}, {.4, -.4, .4, -.4}, {11,21,33,13,23,31,33})
--=|--------------------------------------------------------------------------------------------------------Code: Select all
--name object script_A
function myFunc(pushed)
playSound("secret") hudPrint("Button Pressed "..pushed)
end
Last edited by Isaac on Sun Jan 11, 2015 10:56 pm, edited 1 time in total.
Re: Script: Make Multiple Buttons/Levers
thanks, Isaac. That helps a lot.
Re: Script: Make Multiple Buttons/Levers
It's a neat script; I'm still looking at it. I've not tried using levers yet. The hoops one had to jump through for multiple levers in LoG1 were insane.
- Duncan1246
- Posts: 404
- Joined: Mon Jan 19, 2015 7:42 pm
Re: Script: Make Multiple Buttons/Levers
Hi Lark,Lark wrote: makeControls(self, "wall_button", self.go.id .."_button_", {3, 3}, {.4, -.4, .4, -.4}, {21, 23, 12, 32})
I use your script in my mod, it works fine, thanks you for this nice work!
I needs to use runes-buttons (same as "wall_button" but with a rune instead of the LOG1 logo, named "wall_button_fire", ..., etc. I understand that I have to modify the function "makeControls", but I don't know if it's actually possible without a more complex script. What do you think?
Duncan
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?
Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
download at:http://www.nexusmods.com/grimrock/mods/399/?
Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
Re: Script: Make Multiple Buttons/Levers
The best way to have the runes, is to change the texture on the material... but that's not the easiest way. The second best , is to edit the model in blender an add the rune as a plane, one unit in front of the button face. It will cover the logo, rather than replace it.Duncan1246 wrote:I needs to use runes-buttons (same as "wall_button" but with a rune instead of the LOG1 logo, named "wall_button_fire", ..., etc.
To alter the textures, you could use Blender to bake the changes to the material(s); or you could use Photoshop/Gimp along with the normal map plug-in; to fake the baked results.