Originally I had an idea for a puzzle where I was going to have a timer activate levers or pressure plates. And the party would have to find the secret button or something to stop the timer so that they could use the levers normally. But apparently connecting a timer node to a lever (not lever to timer) does not work or do anything.
So I need a work around in lua scripting. But I don't really know how to begin. I have done some programming and I have edited lua scripts, but I don't really know how to make one from scratch.
Need some help with scripting.
Re: Need some help with scripting.
scripts can toggle levers, but can't directly affect pressure plates in like manner. You could spawn in and later destroy invisible objects to weigh down the plates, I suppose.
Finished Dungeons - complete mods to play
-
zadkielmodeler
- Posts: 43
- Joined: Sat Sep 15, 2012 6:34 am
Re: Need some help with scripting.
I could figure this out if I knew all the action triggers. I can use the scripting reference to make something happen.
But I need to know how to set it to happen.
Like the
onTurn
onMove
a list of these sorts of triggers would be super useful.
But I need to know how to set it to happen.
Like the
onTurn
onMove
a list of these sorts of triggers would be super useful.
-
zadkielmodeler
- Posts: 43
- Joined: Sat Sep 15, 2012 6:34 am
Re: Need some help with scripting.
That's cool, how would you toggle a lever or multiple levers with a lua script on a timer?Komag wrote:scripts can toggle levers, but can't directly affect pressure plates in like manner. You could spawn in and later destroy invisible objects to weigh down the plates, I suppose.
I am sure there is a for loop of some kind involved.
okay I am going to try to code it. double check my work here. Again keyword here is TRY.
function1()
for i = 5, 10, 0 do
Lever1:Toggle()
Lever2:Toggle()
if Secret_button1:push() then
i = 10
else
end
end
Re: Need some help with scripting.
I can try to give you some help.zadkielmodeler wrote:That's cool, how would you toggle a lever or multiple levers with a lua script on a timer?Komag wrote:scripts can toggle levers, but can't directly affect pressure plates in like manner. You could spawn in and later destroy invisible objects to weigh down the plates, I suppose.
I am sure there is a for loop of some kind involved.
okay I am going to try to code it. double check my work here. Again keyword here is TRY.
function1()
for i = 5, 10, 0 do
Lever1:Toggle()
Lever2:Toggle()
if Secret_button1:push() then
i = 10
else
end
end
about the pressure plate, I think Komag is right, you cannot operate them via script - so the spawned object are a good way-, but you can operate levers and buttons with the script lever:toggle() and button:push()
For the secret button, as far as I know, the game can't tell if a button has been pushed or not, so you must connect it to a counter and use its value to tell (0 = not pushed, 1 = pushed).
The script you wrote... well, I bet the game will freeze and you will get a stack overflow error. You use the for loop but it will never ends - at least not in cpu time.
A way to do it is to create a timer and connect it to a script.
the script should be something like:
Code: Select all
function leveraction()
lever1:toggle()
lever2:toggle()
endCode: Select all
function leveraction()
for i = 1, 10 do
findEntity("lever"..i):toggle()
end
endAnd the secret button is connected to the timer, and when is pressed, it must stop it.
-
zadkielmodeler
- Posts: 43
- Joined: Sat Sep 15, 2012 6:34 am
Re: Need some help with scripting.
Thank you so much. It works so well.
