If/Else issue with multiple items.

XanMag
I'm giving away a key hint to my game here so... if you play my game when it is finished, pretend you never saw this! :lol:

I have a thermal lunchbox. Multiple things need to happen to it before it can be used properly. It must be (1) taped and (2) cut with a knife THEN (3) filled with ice THEN (4) filled with the proper 'chemicals'. To represent this in the game, I have four lunchboxes. The first is empty. When taped, I move the empty one to a dead room and add the taped one to the inventory. When it is cut, I move the taped one to the dead room and the taped/cut one to the inventory. When that is filled... yada yada yada... you get the point. So, at the end of the procedure, the player has taped, cut, filled, and filled the lunchbox. At this point it can be used to achieve desired effect.

My problem is this. What if the player does things out of order? For example, a logical thing to do is put ice in a thermal lunchbox, but I do not want that to happen before it is taped and cut. Easy, right? My initial thought was to do an 'If/Then/Else'. When the player tries to take the ice, If 'player is carrying lunchbox (the normal one)', 'Then' 'print message' "You have the right idea here, but the lunchbox is not ready to receive the ice" and the 'Else' would be "You consider picking up the ice, but it would melt too quickly in your hot, sweaty hands."

BUT... as soon as the lunchbox is taped and the normal lunchbox is swapped out, then I will always see the 'Else' message. This is where I stopped messing with it because I see serious confusion for me down the road.

I hope you all get the idea. It's kind of complicated. Is there an easier way of tackling this than what I have designed? Thanks in advance!

EDIT: Just thought of this... Could I use one flag (say 'CPS') to control all of that? Flag goes up when adding a lunchbox... make the lunchbox undroppable... and have one default else under a command for each lunchbox that says something simple, like "Good idea, but not yet!"

The Pixie

BUT... as soon as the lunchbox is taped and the normal lunchbox is swapped out, then I will always see the 'Else' message. This is where I stopped messing with it because I see serious confusion for me down the road.


If I understand you right, at this point the original lunchbox is elsewhere, so Quest should be trying to do this with lunch box two. I would change the alias of each lunchbox at least while testing so you can see exactly which is present at any time.

Beyond that, it would help to know how you are implementing it. Are you using comands or verbs? Can you post up the code?

EDIT: Just thought of this... Could I use one flag (say 'CPS') to control all of that? Flag goes up when adding a lunchbox... make the lunchbox undroppable... and have one default else under a command for each lunchbox that says something simple, like "Good idea, but not yet!"


Personally I would do it with an integer attribute (probably what you mean) that increments at each stage, rather than swapping objects.

XanMag
I've completed a trial and error set up but have yet to test it... I've used a combination of different flags on each lunchbox.

So... Get lunchbox...
1. Flag lunchbox as taken
2. If you try to get ice with flag taken on lunchbox, then print msg "Right idea, wrong order"
3. Use duct tape on lunchbox, swap out lunchbox for lunchbox1, set flag lunchbox as taken2
4. If you try to get ice with flag taken2 on lunchbox, then print msg "Right idea, wrong order"
5. Use knife on lunchbox1, swap out lunchbox1 for lunchbox 2, set flag on lunchbox as taken3
6. If you try to get ice with flag taken3 on lunchbox, then print msg "You fill the lunchbox with ice, set flag icy on lunchbox2
7. Use chemicals on lunchbox2, then print msg "You dump the chemicals and it gets really cold", set flag icy2 on lunchbox2
8. Use lunchbox2 as needed... If lunchbox2 has icy then print msg "Goal accomplished", else if lunchbox has icy flag print msg "You're almost there, but it's not cold enough yet", else "you are not ready to use the lunchbox yet"

It should work, right? Like I said, I haven't tested it yet and I would post the code here, but my lunchboxes are buried under 80+ items in my "item warehouse", my ice, lunchbox, knife, and tape are all in separate rooms. It's a mess.

I've never used integer attributes before but will look into it if this method gives me a major hassle.

I wish there were a way (without code) to copy-paste GUI boxes from one open version of quest to another. If that were the case, I would simply copy-paste all parts of my lunchbox problem into a test game so I could test it there and copy/find just those parts easily to paste-code here on the forum. There isn't, right?

EDIT: And I tried to copy-paste all of the parts into a test room within the game but it got all messed up because of the moving items in and out bit because of the way it is set up with all the different numbered parts, so that's not an option. :lol:

adammadam
well my game has similar things but yeah I had to take every order into account. For example lets say you want to make a toffee apple and you have 3 items, an apple, a stick, toffee. You can use apple with stick to create "apple on stick" then "use apple on stick with toffee" to make a toffee apple. But what if the person uses the toffee with the apple first, well then that has to create an "apple covered in toffee", then you can "use apple covered in toffee with stick".. to create a toffee apple also. soo my hidden storage room has various possible combinations of things the user may or may not make, they all have to be accounted for, but they all lead to the same end product. If the player were to type use toffee on stick, in this case that would give a wrong message, because I would decide that's not a logical step and it should be wrong. With 4 stages it's even more complex, and if I were you I'd just have a few different possible combinations in my hidden storage room.

When you said "BUT... as soon as the lunchbox is taped and the normal lunchbox is swapped out, then I will always see the 'Else' message. This is where I stopped messing with it because I see serious confusion for me down the road." You mean you're still seeing the message of the lunchbox which is not supposed to be there anymore/has been swapped out? In mine I use the "remove object" so its no longer there. e.g. once an apple on stick has been created, the apple is removed and the stick is removed they no longer exist and apple on stick is added to the players inventory.

InfectedBehaviour
I wanted to help out since everyone else helps me lol. Please let me know if this solves your problem.

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Tutorial 3">
<gameid>471f7646-a133-44d4-a46f-a2b365c0116c</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="fridge">
<inherit name="editor_object" />
<inherit name="container_open" />
<alias>Fridge</alias>
<usedefaultprefix />
<feature_container />
<isopen type="boolean">false</isopen>
<look>A fridge with a built in freezer.</look>
<object name="freezer">
<inherit name="editor_object" />
<inherit name="container_open" />
<alias>Freezer</alias>
<feature_container />
<isopen type="boolean">false</isopen>
<look>A freezer.</look>
<object name="ice">
<inherit name="editor_object" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<take />
<alias>Ice</alias>
</object>
</object>
<object name="chemicals">
<inherit name="editor_object" />
<take />
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<object name="table">
<inherit name="editor_object" />
<inherit name="surface" />
<alias>Table</alias>
<feature_container />
<look>A wooden table.</look>
<object name="tape">
<inherit name="editor_object" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alias>Duct tape</alias>
<look>A roll of duct tape.</look>
<take />
<cut type="scriptdictionary">
<item key="knife">
if (Contains (deadroom,taped)) {
MoveObject (taped, deadroom2)
MoveObject (cut, deadroom2)
MoveObject (taped, deadroom2)
MoveObject (order2, deadroom2)
if (Contains (deadroom2,order2)) {
MoveObject (order1, deadroom2)
msg ("You successfully cut the extra tape off the lunchbox.")
}
}
else if (Contains (deadroom,order2)) {
msg ("You cut the tape and wonder, Why you cut it in the first place.")
}
else {
msg ("Oops, I cut myself.")
}
</item>
</cut>
<tape type="scriptdictionary">
<item key="lunchbox">
if (Got(tape)) {
MoveObject (taped, deadroom)
if (Contains (deadroom,taped)) {
MoveObject (order1, deadroom2)
msg ("You successfully tape the lunchbox.")
}
}
else {
msg ("This seems wrong.")
}
</item>
</tape>
</object>
<object name="lunchbox">
<inherit name="editor_object" />
<inherit name="container_open" />
<alias>Lunchbox</alias>
<take />
<feature_usegive />
<feature_container />
<isopen type="boolean">false</isopen>
<look type="script">
if (Contains (table,lunchbox)) {
msg ("It's a lunchbox.")
}
else if (Contains (deadroom,taped)) {
msg ("The lunchbox has tape around it but there is still extra tape left over.")
}
else if (Contains (deadroom2,cut)) {
msg ("The lunchbox has tape around it.")
}
else if (Contains (deadroom2,ice2)) {
msg ("It's a lunchbox with tape and ice inside it.")
}
else if (Contains (deadroom2,order4)) {
msg ("It's a thermal lunchbox.")
}
</look>
<useon type="scriptdictionary">
<item key="tape">
msg ("You wrap the tape around the lunchbox.")
MoveObject (taped, lunchbox)
if (Contains (,)) {
}
</item>
</useon>
<fill type="scriptdictionary">
<item key="ice">
if (not lunchbox.isopen) {
msg ("I need to first open it.")
}
else if (lunchbox.isopen) {
if (Contains (deadroom2,order2)) {
MoveObject (ice, lunchbox)
MoveObject (cut, deadroom3)
MoveObject (taped, deadroom3)
MoveObject (order3, deadroom2)
if (Contains (deadroom2,order3)) {
MoveObject (ice2, deadroom2)
msg ("You fill up the lunchbox with the ice.")
}
}
else if (Contains (deadroom,order3)) {
MoveObject (ice, lunchbox)
msg ("I don't think this is right.")
}
}
else {
msg ("The ice is melting.")
}
</item>
<item key="chemicals">
if (lunchbox.isopen) {
if (Contains (deadroom2,order3)) {
MoveObject (order4, deadroom2)
if (Contains (deadroom2,order4)) {
MoveObject (chemicals, lunchbox)
MoveObject (ice2, deadroom3)
MoveObject (thermal, deadroom3)
msg ("Nice. A thermal lunchbox.")
}
}
else if (Contains (deadroom,order4)) {
MoveObject (chemicals, lunchbox)
msg ("This really does not look right. I need to start over.")
}
}
else if (not lunchbox.isopen) {
msg ("To fill it, I need to open it first.")
}
else {
msg ("Hmm.")
}
</item>
</fill>
<object name="cut">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="taped">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<object name="knife">
<inherit name="editor_object" />
<alias>Knife</alias>
<look>A sharp knife.</look>
<take />
</object>
</object>
</object>
<object name="deadroom">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<object name="order1">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="order2">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="order3">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="order4">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="ice2">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="thermal">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
</object>
<verb>
<property>cut</property>
<pattern>cut</pattern>
<defaultexpression>"You can't cut " + object.article + "."</defaultexpression>
</verb>
<object name="deadroom2">
<inherit name="editor_object" />
<visible type="boolean">false</visible>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<verb>
<property>tape</property>
<pattern>tape</pattern>
<defaultexpression>"You can't tape " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>fill</property>
<pattern>fill</pattern>
<defaultexpression>"You can't fill " + object.article + "."</defaultexpression>
</verb>
<object name="deadroom3">
<inherit name="editor_object" />
</object>
</asl>


I did that only using the GUI and to what the others have said, I think I did it right.

The Pixie
XanMag wrote:I've completed a trial and error set up but have yet to test it... I've used a combination of different flags on each lunchbox.

So... Get lunchbox...
1. Flag lunchbox as taken
2. If you try to get ice with flag taken on lunchbox, then print msg "Right idea, wrong order"
3. Use duct tape on lunchbox, swap out lunchbox for lunchbox1, set flag lunchbox as taken2
4. If you try to get ice with flag taken2 on lunchbox, then print msg "Right idea, wrong order"
5. Use knife on lunchbox1, swap out lunchbox1 for lunchbox 2, set flag on lunchbox as taken3
6. If you try to get ice with flag taken3 on lunchbox, then print msg "You fill the lunchbox with ice, set flag icy on lunchbox2
7. Use chemicals on lunchbox2, then print msg "You dump the chemicals and it gets really cold", set flag icy2 on lunchbox2
8. Use lunchbox2 as needed... If lunchbox2 has icy then print msg "Goal accomplished", else if lunchbox has icy flag print msg "You're almost there, but it's not cold enough yet", else "you are not ready to use the lunchbox yet"

It should work, right? Like I said, I haven't tested it yet and I would post the code here, but my lunchboxes are buried under 80+ items in my "item warehouse", my ice, lunchbox, knife, and tape are all in separate rooms. It's a mess.

I've never used integer attributes before but will look into it if this method gives me a major hassle.

I wish there were a way (without code) to copy-paste GUI boxes from one open version of quest to another. If that were the case, I would simply copy-paste all parts of my lunchbox problem into a test game so I could test it there and copy/find just those parts easily to paste-code here on the forum. There isn't, right?

EDIT: And I tried to copy-paste all of the parts into a test room within the game but it got all messed up because of the moving items in and out bit because of the way it is set up with all the different numbered parts, so that's not an option. :lol:

I think you are making it more complicated than it needs to be. You do not need a flag to say it is taken, Quest can check that (in code, check if the parent is player, I think in the GUI you just check if the player has it). Either use one lunch box and flag its state (or use an integer attribute, which would be my choice), or use multiple lunchboxes, one for each state, with no flags. What you propose above has the worst of both options.

adammadam
yeah you need to use
"if player is not carrying object" e.g. use stick with apple. If player is not carrying apple "you have no apple" else if player is not carrying stick "you have no stick" else remove object stick, remove object apple, add to inventory apple on stick.

then use toffee on apple with stick.. if player is not carrying toffee "you have no toffee" else if player is not carrying apple on stick "you dont have an apple on a stick" else remove object toffee, remove object apple on stick, add to inventory toffee apple

XanMag
I guess part of my issue was that it had to be done in a certain order so that complicated matters. Plus, in the countless hours I've messed with Quest, I've never known there was a remove object script!

I'm going to leave as is until I check it, but will definitely come back to this is my jumbled mess returns a ton of errors! I think it'll work the way I did it, but this will certainly help in the future. Thanks, all!

adammadam
if it has to be done in a certain order, it should be easier I think.

Lunchbox object - cut with knife "you need to tape it first", fill with ice "you need to cut and tape it first", fill with chemicals "you need to tape, cut and fill it with ice first" (or of course whatever messages you want). Tape - "you tape the lunchbox" remove object lunchbox, add to inventory taped lunchbox

taped lunchbox object - tape "youve already done that", fill with ice "you need to cut it first", fill with chemicals "you need to cut and fill it with ice first". Cut - "you cut the lunchbox" remove object taped lunchbox, add to inventory taped and cut lunchbox

taped and cut lunchbox object - tape "youve already done that", cut "youve already done that", fill with chemicals "you need to fill it with ice first", fill with ice "you fill it with ice" remove taped and cut lunchbox, add to inventory ice filled lunchbox

ice filled lunchbox - add chemicals "you add them" remove item ice filled lunchbox, add to inventory thermal lunchbox.. (and all others youve already done that or whatever messages you want.)

idk if maybe it wasnt working because the previous object was staying visible in the room for you, with remove object it works well. But make sure to set that storage room as not being visible also so the player cant look at all the things that are in it

If you want it to be done in a certain order, then I think theres no need for if/else or object flags or anything, since only one of the verbs will work on each object and transform it to the next one, all the others can just give messages that you need to do something else first or that you've already done that verb.

Father thyme
Perhaps if you have too many things in your warehouse you could create a lunchbox warehouse. Although I find making things invisible works for me ,(rather than putting them in a sealed room.) if you are carrying them they will move with you.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums