Hi there,
1. I have a few levers, let's call them lr_1 to lr_6
2. Each lever has onToggle hook to function called checkLever
3. Inside this function - how can I check which lever actually activated the function ?
Is that even possible ? I couldn't find any info in reference...
thanks in advance,
Blichew
[Question] Checking what activated function
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: [Question] Checking what activated function
Here is how I would do this:
I would have each lever connect to two functions. One of them is your main function and another one is unique to each lever that just sets a boolean variable. Then you can find out if the boolean is true or false in your main function.
I would have each lever connect to two functions. One of them is your main function and another one is unique to each lever that just sets a boolean variable. Then you can find out if the boolean is true or false in your main function.
Re: [Question] Checking what activated function
Code: Select all
function checkLever(sender)
print(sender.go.id) -- this should print the name of the pulled lever.
end
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: [Question] Checking what activated function
I believe the 1st parameter passed to an onToggle function is the object that triggered it.
So if you had something like:
I think you would see your leve's id printed. "onToggle" may pass a 2nd argument as well. The state of the lever, true or false.
So if you had something like:
Code: Select all
onToggle = function(obj)
print(obj.go.id)
end
Re: [Question] Checking what activated function
That was fast, thank you ![Smile :)](./images/smilies/icon_e_smile.gif)
I've already started doing a workaround with separate function for each lever which sets a boolean var...
![Smile :)](./images/smilies/icon_e_smile.gif)
I've already started doing a workaround with separate function for each lever which sets a boolean var...
Re: [Question] Checking what activated function
much better to do it proper and read the parameter than to set up a bunch of unnecessary functions
Finished Dungeons - complete mods to play