Inventory problems PLEASE HELP ASAP!!!

Okay, so this is gonna be super complicated but I'll explain as simply as possible.

I'm basically making a game for an assessment that's due in a few weeks. I'm first year in a serious games design course so I know next to nothing about coding atm.

I went through the Quest tutorial. Everything was going great, I was getting the hang of everything easily enough. But now I've run into an inventory problem that I can't work out. I've spent hours going through the forums and trying different things but I can't make it work for me, so here I am.

My character is meant to be going on a journey, in the first part she has to escape her home and she has to take some supplies with her. The catch is, there are four supplies (objects) available, and the player can only choose 2 for the character to take. They're all important. And the player's choice has consequences later on in the story.

2 objects are in one room (kitchen) the player has to choose between these two. Then they go to another room (sleeping area) where the other two objects are. They have to then choose between these two. So, basically, they can only take one object from each room.

Here's where I ran into trouble. The player can take the objects and they show up in the inventory, which is great. But, I want it so that if the player chooses one object in the room they can't put the other object in their inventory as well (otherwise what's the point in making the player choose if they can just put both in the inventory anyway, right?).

To solve this issue, I tried "If ..." statements. To keep this simple let's just stick with one room and 2 objects. I went to the inventory options of the objects in the kitchen. I went to "Take" and selected "run script" to put in the "If ..." statement. Which was basically "If you're carrying this object, you can't pick up the other blah blah blah". I thought it would work, but when I played through to test it, I could pick up the objects but neither of them showed up in my inventory in the panel, nor were they there when I typed in the inventory command, even though it ran the "You picked blah blah blah up" when I took the object. I don't have either of them checked as scenery, so that's not the problem. And because they didn't show up in the inventory, I didn't get the message of "you can't pick up this object because you have the other in your inventory" when I tried to pick up both objects. It just let me pick them both up.

So, anyway, I went back and tinkered with it. Eventually, I set the "Take" option as "Default Behaviour" and made sure the "Object can be taken" box was checked. THEN I went to the "After taking the object" section and put the "If ..." statements in there. So, I was hoping that it would work out like "You've picked up this object, but oh wait, you've already picked up this other one so now you have to choose". I played through again and it all worked just as I wanted it to. EXCEPT even though the text was telling you to choose, both items were in the inventory, so a player could just go "I'm not gonna choose, they're both in my inventory".

I tried adding a new script in the "Then" statement called "Remove object" (or something along those lines) hoping it would just remove one of the objects from the inventory if the player picked the 2nd one up, but when I did the play through it just came up with an error.

So, now I'm stuck. How do I work this so the player can only have 1 object from each room in the inventory? Or is there a way where I can trap them so they can't progress through the game until they make a choice and drop one of the items from the inventory?

I need an answer ASAP as I only have 2 weeks before the assessment it due. I'm not great at understanding complex coding so try and keep it simple, please? I'd ask my tutor but I live so far away from the university and I know she'll want me to go in so she can see it in person. I just don't have the time for that as I have other assessments for other classes too.

Thanks guys!


To solve this issue, I tried "If ..." statements. To keep this simple let's just stick with one room and 2 objects. I went to the inventory options of the objects in the kitchen. I went to "Take" and selected "run script" to put in the "If ..." statement. Which was basically "If you're carrying this object, you can't pick up the other blah blah blah". I thought it would work, but when I played through to test it, I could pick up the objects but neither of them showed up in my inventory in the panel, nor were they there when I typed in the inventory command, even though it ran the "You picked blah blah blah up" when I took the object. I don't have either of them checked as scenery, so that's not the problem. And because they didn't show up in the inventory, I didn't get the message of "you can't pick up this object because you have the other in your inventory" when I tried to pick up both objects. It just let me pick them both up.

This should work, and is how I would do. Say the two objects are knife and rolling pin. On the rolling pin, the script would be this (I appreciate some people do not like code, but bear with me here):

if (Got(knife)) {
  msg ("You are already carrying the knife.")
}
else {
  AddToInventory (this)
}

To get this in your game, go to the first object's take script, and click on code view. Paste in the above, and then change "knife" to the name of the other object (two places). Click on code view again, and you will see it in the usual GUI way.

Do that for all four objects, swapping "knife" in each case for the item that stops this one being taken.


Thank you so much, Pixie! Believe it or not I actually just came back here to make an edit and say I worked it out. Thanks for the help, though :)


awesome job! (this is not easy to figure out) How did you go about getting it to work?


after you're done with all your school work, if you're still interested in using quest to make games, and are interested in learning to code in quest and/or just understand quest better (as the tutorial only teaches you the basics of using the quest GUI/Editor, as you're learning game making/design, you should know that you need to learn how to be able to do actions/events for your game having cool features/functionality, which is done via quest's Attributes and the 'if' Script usage, which will allow you to do 90% of everything you want to do in/for a game/game-making), you can take a look here:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
(it is a bit code heavy/oriented, but I do tell/show how to do this stuff in/through/with/via the GUI/Editor too)

and here's a step by step walkthrough guide on making your own demo game on learning the basics of Attribute usage:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375


ask if you need help or have questions on anything


Thanks for the resources! In the if-then statement, I just put the "then" as moving the object back to its original source using the GUI. It was a pretty simple fix actually, I'm not sure how I missed it earlier. Muddled mind from all the work I guess XD


Could this work?
"Get knife"
script disables "take rolling pin"
(you can now not take the rolling pin.)
"drop knife"
script enables "take rolling pin"

How would that look in code?
without using IF?


You could create a Boolean flag on the player and call it say cutlery and set it as False.
Then check that flag hasn't been set when player attempts to pick up the items in question by running a script on Take/Drop

Example for Take knife:

if (not GetBoolean(player, "cutlery")) {
  msg ("You take the knife")
  SetObjectFlagOn (player, "cutlery")
  AddToInventory (this)
}
else {
  msg ("You may only take one or the other (Knife or Rolling Pin)")
}

Example for Drop knife:

MoveObjectHere (this)
SetObjectFlagOff (player, "cutlery")
msg ("You drop the knife.")

And do the same for the Rolling Pin
Example Take Rolling Pin:

if (not GetBoolean(player, "cutlery")) {
  msg ("You take the rolling pin")
  SetObjectFlagOn (player, "cutlery")
  AddToInventory (this)
}
else {
  msg ("You may only take one or the other (Knife or Rolling Pin)")
}

Example for Drop rolling pin:

MoveObjectHere (this)
SetObjectFlagOff (player, "cutlery")
msg ("You drop the rolling pin.")

@ Dark Lizard:

(as seen by Pixie's post, my post, and crusader's post, there's many ways of handling the what the OP-Ironnakeesi needed/asked help of)

another way is via:

the Verb displayment/assessibility is controlled by the built-in 'displayverbs' and/or 'inventoryverbs' Stringlist Attributes, which allows you to add/remove the Verbs from these Stringlist Attributes

for example:

<object name="example_object">

  <attr name="displayverbs" type="simplestringlist">deplete</attr> // initial (and only) Verb revealed/useable/accessible: as a button and as hyperlink for this 'example_object' Object

  <attr name="deplete" type="script">

    msg ("you depleted your energy")

    list remove (example_object.displayverbs, "deplete") // this Verb is removed/hidden: it's no longer a clickable button and nor hyperlink

    list add (example_object.displayverbs, "recharge") // this Verb is added/revealed: it's now a clickable button and hyperlink

  </attr>

  <attr name="recharge" type="script">

    msg ("you recharged your energy")

    list remove (example_object.displayverbs, "recharge") // this Verb is removed/hidden: it's no longer a clickable button and nor hyperlink

    list add (example_object.displayverbs, "deplete")  // this Verb is added/revealed: it's now a clickable button and hyperlink

  </attr>

</object>

<verb>
  <property>deplete</property>
  <pattern>deplete</pattern>
  <defaultexpression>You can't deplete that!</defaultexpression>
</verb>

<verb>
  <property>recharge</property>
  <pattern>recharge</pattern>
  <defaultexpression>You can't recharge that!</defaultexpression>
<verb>

an example of toggling between the Verbs, ask if you got any questions or need help with anything.


I think, on several things Quest, I don't know enough to know what to ask...


I had the problem too when I was first learning quest ~ 5-6 years ago, hehe

did you understand my code above?, the same can be done for your: get knife disable take rolling pin, I just used a sample example


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

Support

Forums