First off is the problem I'm having.
Im creating a script for a puzzle in my custom story which works smoothly for the most part. The only error is in the fact that you can still move the pieces of the puzzle once it's completed, though the if()'s in the script should prevent that.
Here is the script below.
The puzzle involves pressing levers into their slots, which will toggle the position of certain other levers. When they're all pushed down, the variable "leverpuzzle_var" should equal 6 (for 6 switches pressed.) However, theres either an error in control flow or with the variable, as I can still toggle the levers after I push all 6 in.
Anyone see the problem here?
Oh, and the if "levers_functional" is for another part I'm adding later, but for now its set to be true (aka '1') as default, so Ignore that.
Oh, and secondly. When theyre all pushed in I want to have another function run. What is the best way of doing that?
THANKS
(This post was last modified: 07-28-2014, 04:33 AM by Vale.)
Those levers may be increasing the value of that variable several times cause you're using SetEntityPlayerInteractCallback to trigger the function instead of a callback that detects only when the state changes.
If I'm correct, you should see that variable getting too big by the time you finished the puzzle, so it's always > than 6 and the code keeps on.
Mmm. You misunderstood, and I underdescribed. It uses examine areas for interaction to toggle their states, because they aren't quite... levers. However, I will take your advice and monitor the value of the variable. Thanks for your time.
Oh. Ok. Yeah you should still check what's happening with that var.
Can't you disable a lever area after the player was done with it? Or you need it for later?
(07-27-2014, 05:09 AM)valetheimpaler Wrote: Mmm. You misunderstood, and I underdescribed. It uses examine areas for interaction to toggle their states, because they aren't quite... levers. However, I will take your advice and monitor the value of the variable. Thanks for your time.
You could just deactivate the examine area when you're done...
(07-27-2014, 02:07 AM)valetheimpaler Wrote: Oh, and secondly. When they're all pushed in I want to have another function run. What is the best way of doing that?
Call a new function. Name the function whatever you want and then after that put (); (refer to first code below). After that your function is basically done. For the callback, use the same function line but don't use the semi colon (refer to second code below). Below is an example (refer to last code).
Alright first captain, that answers my second question. Thank you. http://pastebin.com/SFP0z0Hx
There's a link to the code.
And I'll post a video so you can understand what the puzzle is exactly.
holy jeezus, I figured it out. Theres one tiny error in my code, which originates from me copying and pasting that switch piece and inputting new numbers for each.
Look at the switch after line 65 in the pastebin and you can probably see whats wrong.
When I was trying to get a video of the puzzle I managed to get it to stop while one lever was still up, so I figured that there was an error along those lines.
Thanks again, and sorry for the trouble!
(This post was last modified: 07-27-2014, 02:15 PM by Vale.)