Full Version : Triggering based on state of 3+ objects
xmlspawner >>Q&A >>Triggering based on state of 3+ objects
<< Prev | Next >>
olsyke- 05-06-2006
im trying to build a lever puzzle and need to have a spawner hat checks for the lever states and triggers when every lever is in the right state
i found in the "how do I" section that for one lever it would be...

CODE
1 IF/GETONSPAWN,leverspawner,1,state=0/33 2 GOTO/1 33 SETONSPAWN,dooropener,1/proximityactivated/true/nextspawn/0

but since im haveing 3+ levers wich should be in the correct state to solve the puzzle im have no idea on how to solve this
slida- 05-06-2006
I'm gonna take a crack at answering this.
I think what you do is just have 3 if statements in your first line
1 IF/GETONSPAWN,leverspawner,1,state=0/IF/GETONSPAWN(the next lever & desired state)/IF/GETONSPAWN(the last lever and desired state)/33
I think this would work. If the first check is succesful it will move on to the next check, and if that's succesful then it will move to the third, and if that's succesful it will go to 33, otherwise loop. Anyway, if you come back before Arte has time to answer give that a shot.
olsyke- 05-06-2006

CODE
1 IF/GET,Stiege#1,location=(5177,93,5)/ IF/GET,Stiege#2,location=(5176,93,10)/ IF/GET,Stiege#3,location=(5175,93,15)/ 33 2 GOTO1
33 orc

okay thats how far i got... i made 3 levers that control a stonestair each and now i need this spawner to be triggered when the 3 stonestairs are moved to the defined locations
as you may see this is the code you submitted above just altered to fit my needs
now the problem is that i get this error msg -> invalid elsegroup arg to IF
*edit

CODE
1 IF/GET,Stiege#1,location=(5177,93,5)/3 2 GOTO/1 3 IF/GET,Stiege#2,location=(5176,93,10)/5 4 GOTO/1 5 IF/GET,Stiege#3,location=(5175,93,15)/7
6 GOTO/1
7 orc

after further investigation on this case i made up this piece of code and from my opinion this would be the most logical way and even this returns no errors...
but the downside is it still doesnt get triggered when the stair pieces hit the right spot...
any ideas ?
ArteGordon- 05-06-2006
there is another way to do this that I think is easier. The CombinationLock item lets you look for configurations of multiple states, such as lever positions.
from xmlspawner2.txt

QUOTE
CombinationLock simulates a multi-digit (max 8) combination lock. The state of each of the digits can be set using (for example) the lever or switch items. The combination is set in the Combination property. So the combination of 378, would correspond to digits 2,1,0 taking on values of 3,7, and 8 respectively. The Match property can be tested to determine when the target combination is matched by the combination of digits.
Note that digit number corresponds to significance, from least to most.
Each digit is a property (Digit0, Digit1, Digit2, ... Digit7) and can take on the values 0-9. You can set the property string to indicate either a property name on the target item (e.g. switchstate, or leverstate, or totalgold), or you can specify a test such as totalgold<100, or open=false, or locked=true.
You could use this item to look for certain combinations of switches or levers, door states, etc. or even combinations of levers, and weight of a container, or number of kills on a spawn etc., and then open a door, or add items to a container, or change the color of a stone, trigger a spawn, etc.

Just set the Digit0Object, Digit1Object, and Digit2Object properties to point to your switches. And then set the Digit0Property, Digit1Property, and Digit2Property properties to test for the lever state, by just assigning them to "LeverState"
Then set the Combination property to the lever combination value that you want, like 101 for lever0 in the 1 state, lever2 in the 0 state, and lever2 in the 1 state.
The Matched property on the CombinationLock will be true when the combination is matched.
olsyke- 05-06-2006
ah i just edited my previous post while you answered, please review above
ArteGordon- 05-06-2006
you should be able to use a compound test like
IF/GET,Stiege#1,location=(5177,93,5) & GET,Stiege#2,location=(5176,93,10) & GET,Stiege#3,location=(5175,93,15)/7
You will need to have the beta_309.zip modification installed which fixes a problem with multiple compound tests.
olsyke- 05-06-2006
well...
the problem is i dont have access to the server scripts
i tried your advice with the combination lock but when i set the digit#prop to "location" it always returns -1 no matter at what location the stair tiles are and so it always results in a combination of -111 wich cant be set
in this riddle you use 3 state levers to move the stairs around and because of this there is no combination of lever states that renders this riddle solved, only the combination of the stairs locations can do this

CODE
1 IF/GET,Stiege#1,location=(5177,93,5)/3 2 GOTO/1 3 IF/GET,Stiege#2,location=(5176,93,10)/5 4 GOTO/1 5 IF/GET,Stiege#3,location=(5175,93,15)/7
6 GOTO/1
7 orc

do you see any possibility of making the above work - because im affraid im running out of options here
ArteGordon- 05-06-2006
what is the object that you are setting the Digit#Object to point to?
If you point to the lever that is moving the stairs, then use the "leverstate" property.
If you are pointing to the actual stair objects, and you want to test for the position, then you can set the Digit#Prop property to something like "location=(5177,93,5)". That will have a value of either 1 or 0 depending on whether it is true or not. That will be a valid single digit.
When you just set it to "location", that returns a complex string like "(5177,93,5)" and not a single digit from 0-9 which is what is required for use in the combination. That is why it didnt work.
olsyke- 05-06-2006
okay well i was pointing at the stairs directly since their location is the key to the success
i just managed to get that part to work but the solution is somewhat stupid

CODE
location=(5176,93,5)

)
that was what i used all the time in the digit#prop and diddnt work for me all the time...
then i used "props" again on my first pair of stairs and noticed that the actual typing there was ->(5176, 93, 5)
so when you insert the spaces it actually starts working, probly the xmlspawner version here is an outdated one
and thanks for your help again i hope i'll manage to get the rest running on my own now
ArteGordon- 05-06-2006
yes. It needs to look exactly like the value that is found in props or returned by [get.
olsyke- 05-06-2006
well looks like i turned on the parylights too early...
i just figured that the Digit# values always return as 1 wether the objects are in the right location or not always giving me the current value 111
*aims to throw the towell*
ArteGordon- 05-07-2006

QUOTE (olsyke @ May 06, 2006 11:53 pm)
well looks like i turned on the parylights too early... i just figured that the Digit# values always return as 1 wether the objects are in the right location or not always giving me the current value 111 *aims to throw the towell*

I will check it out.
(edit)
I just tried it out using 3 wall segments and the property tests for location and it worked fine. I got the various combinations when I moved different pieces, and ony got the matching value of 111 when all pieces were in their desired locations.
I would double check to make sure that the Digit#Object properties are pointing at the correct objects, and that the Digit#Property location tests are checking for the exact values that are returned when you do a [get on each corresponding stair piece when they are in the position that you want, like
location=(5176, 93, 5)
One other thing to check is to make sure that you are not respawning these stair pieces.
When you point to them with the Digit#Object property, it is referring to that exact object. If you respawn it, then that object will be replaced by a different object with a different serial number and so the Digit#Object property will no longer be valid.