inventory script

Started by dikla, Mon 10/05/2004 20:11:14

Previous topic - Next topic

dikla

 i need an easy script for:
I have 5 items which i need to use on hotspot in a certain order (like in kyrandia potions).
the hotspot is "pot" and the items are: 1, 2, 3, 4, 5.
I had some ideas but I am not very good at scripting. pls help - even general idea. also i don't know weather  put the script in hotspot or in inventory (since all the items (1-5) needed are in the inventory).
thank you!
dikla

Scummbuddy

what would you want to happen if the user doesn't put them in in the correct order?
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

dikla

for each item it will say "you put  1" and after the last item if it not the correct order it will say "nothing happen" (or maybe after each item - what do you suggest?) and if it will be correct order (he has a recipe) display massage: "very good - you've made the medicin" or something.
thank you!

Ginny

#3
Right, well firstly, you need to put the script in hotspot interactions, not inventory, because the interaction editor works in a way that it check if the player interacted with the object/hotspot/item/character, not if the player used the item to interact with something else. In this case, since interacting with the pot needs to be done with items, you use the "Inventory used on hotspot" interaction (I don't remember the exact wording, but you get it). Now, suppose you have the 5 items, 1-5, and the order they need to be put in is 23451. First, you need a integer (a variable that stores a whole number) to see if the player has started the sequence correctly and how he is progressing. If I recall correctly, strazer answered a similar question you asked before, and the way to script this is similar to the buttons.

----------
// in the game_start() function of the global
// this sets the globalint for the sequence to zero
/* actually you don't need this at all, you just need to choose a global int number to use for the sequence. it helps to write this with a comment about it's purpose, imo */

SetGlobalInt(5,0);
//Global Int number 5 will be used for the potion sequence

// in the script for "player uses inventory on this hotspot"

int itemused = character[GetPlayerCharacter()].activeinv;
//not neccessary, just for convenience
//this will store the item number that was used

if ((GetGlobalInt(5); == 0) && (itemused == 2) {
//if the first item in the sequence was used
LoseInventory(2);
sequence++;
Display("You used the correct ingredient, what's next?");
}

else if ((GetGlobalInt(5); == 1) && (itemused == 3) {
//if the second item in the sequence was used
LoseInventory(3);
sequence++;
Display("You used the correct ingredient, what's next?");
}

else if ((GetGlobalInt(5); == 2) && (itemused == 4) {
//if the third item in the sequence was used
LoseInventory(4);
sequence++;
Display("You used the correct ingredient, what's next?");
}

else if ((GetGlobalInt(5); == 3) && (itemused == 5) {
//if the fourth item in the sequence was used
LoseInventory(5);
sequence++;
Display("You used the correct ingredient, what's next?");
}

else if ((GetGlobalInt(5); == 4) && (itemused == 1) {
//if the fifth item in the sequence was used
LoseInventory(1);
Display("You have finished the potion! Well done! Bla bla bla...");
/*result of completing the potion. could be an item given or anything else*/
}

else {
Display("This is the wrong potion ingredient to put in right now.");
}
----------

There are more complicated ways to do this, which would allow the player to put the items inside in any order and then discover the result is wrong, so he'll get the items back, or find them again, etc..
Also, if you need other items to be used on the pot before or later, you need to change the else { ... } to:

-----
else if ((itemused == 1) || (itemused == 2) || (itemused == 3) || (itemused == 4) || (itemused == 5)) {
Display("This is the wrong potion ingredient to put in right now.");
}
-----

Or just make sure it's at the very end of the interaction (though that might not work).

P.s. Where are you from dikla, if you don't mind my asking? :)

Edit: Ah, ok, I didn't see your latest post until now.
Doing it the way you want is a bit more complicated, but not that different actually. I don't have time right now, but if you still need help I can write it up tommorow. :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

As for making it to display the result once the last item has been used youÃ, can do the following:

Select the "pot" hotspot, open its interactions, choose Use inventory on hotspot, next RunScript and put the following script:

if (StrLen(sequence) < 5) {

   int item = character[GetPlayerCharacter()].activeinv;
   Display("put %d", item);
   StrFormat(sequence, "%s%d", sequence, item);

   if (StrLen(sequence) == 5) {

      if (StrCaseComp(sequence, "12345")==0) {
         Display("very good - you've made the medicin");
      } else {
         Display("nothing happen");
         StrCopy(sequence, "");
      }
   }
}


Next, open the interaction editor, choose Player - enters screen (before fade-in), select RunScript action and put the next line of script:

StrCopy(sequence, "");


And finally, open the whole room script ("{}" button) and at the very *top* of it put:

string sequence;

How did it turn out?

SMF spam blocked by CleanTalk