how do i script to increment and decrement a counter using lua?
I cant find any example of this .......
how to decrement/increment a counter using script
Re: how to decrement/increment a counter using script
Do you want a counter written in lua or do you want to change the counter with lua?
if you want to change a counter with lua use the functions for counters:
if you want to change a counter with lua use the functions for counters:
Code: Select all
Counter:increment()
Increments the value of the counter by 1.
Counter:decrement()
Decrements the value of the counter by 1.
Re: how to decrement/increment a counter using script
I tried:
function blueGems()
if rightBlueGem == "true" or leftBlueGem == "true" then
counter_4:decrement()
end
end
and it worked ( using conectors to the eyesockets)
function blueGems()
if rightBlueGem == "true" or leftBlueGem == "true" then
counter_4:decrement()
end
end
and it worked ( using conectors to the eyesockets)
Re: how to decrement/increment a counter using script
counter_4:decrement() ![Smile :)](./images/smilies/icon_e_smile.gif)
e: fu too late ._.
![Smile :)](./images/smilies/icon_e_smile.gif)
e: fu too late ._.
Last edited by Akatana on Sun Sep 16, 2012 3:26 pm, edited 1 time in total.
Re: how to decrement/increment a counter using script
yeah i forgot to place connectors....
Re: how to decrement/increment a counter using script
There is also another alternative in the code:
example by petri
I presume with this method you could have the counter go up or down more than 1 if you wanted, such as "counter + 3", which could be very useful in certain circumstances
example by petri
Code: Select all
counter = 2
function activate()
counter = counter - 1
checkValue()
end
function deactivate()
counter = counter + 1
checkValue()
end
function checkValue()
if counter == 0 then
door:open()
else
door:close()
end
end
Finished Dungeons - complete mods to play