Object Interaction Problems

Started by rock_chick, Tue 24/08/2004 10:14:27

Previous topic - Next topic

rock_chick

I have an object(chest). I use the interaction to get the character to go over, run animation for opening, get some items and then the chest closes. There's also a add points thing there in the middle as well as a message saying what they've recieved. I then try to add a conditional so that doing the same thing a second time just uses the opening and closing animations with a message that its empty in between. I've tried using a variable change and if a item has something in their inventory but instead it just goes straight through the first step, then straight to second condition. If you try it again though the same things happens rather than just the second condition. Any help would be much appreciated!
Kat :)

Gilbert

Maybe your interactions are not indented correctly within the conditions?

If it couldn't help, you can also take a screeshot of how you set the interactions in the interaction editor for us to check if there's a problem in it.

Albert Cuandero

It is exactly the same thing as displaying a different message when the player loks at the Hotspot for a second time.

If you use the interactoin editor you must think as the AGS thinks. It does not choose the first true option and then stops (except you tell it to stop there) but goes on doing whatever is true at the very moment.

Thus for this you should use a variable ("Game-Set Variable value") make a variable like chest_open. It starts at 0 so all you need to do is:

-Condition - if chest_open is 0, open it, give points, add items blahblahblah, set chest_open to 1

-Condition - if chest_open is 1, open it, display message, close it.

Note that defining just one general thread (with points and items addition) and one conditional won't work.
int do_you_like_me;
if (do_you_like_me == 1) Display ("You can call me Al");
else {}

Ashen

Just a small correction, I think it should be:

-Condition - if chest_open is 0, open it, give points, add items blahblahblah, set chest_open to 1, close chest, STOP RUNNING MORE COMMANDS

-Condition - if chest_open is 1, open it, display message, close it.

Otherwise, it goes straight onto 'if chest_open is 1', as rock_chick said. Alternatively, put 'if chest_open is 1' before 'if chest_open is 0'

-Condition - if chest_open is 1, blah blah blah
-Condition - if chest_open is 0, blah blah blah
I know what you're thinking ... Don't think that.

Edwin Xie

Maybe you could try doing a script?:

if (NAMEONEVARIABLE == 0){
  AnimateObject (object,loop,delay,repeat);
  ObjectOff(closedchest);
  ObjectOn (openchest);
  AddInventory (InvItem);
  GiveScore (scorenumber);
  Display ("You have received scorenumber points!");
  ObjectOff(openchest);
  ObjectOn (closedchest);
  NAMEONEVARIABLE = 1;
  }
if (NAMEONEVARIABLE == 1){
  ObjectOff (closedchest);
  ObjectOn (openchest);
  Display ("There is nothing in the chest");
  ObjectOff (openchest);
  ObjectOn (closedchest);
  }
You have to rename the letters inside the (); NAMEONEVARIABLE can be renamed to open_chest, closedchest and openchest is for the object number of the open and closed chest. Scorenumber is for how much points you want the player to recieve. InvItem is what inventory item you would like the player to receive. If you want the player to recieve more items you can always duplicate "AddInventory (InvItem);".  There is a piece of the script called "AnimateObject (object,loop,delay,repeat);", inside the () are, "object", "loop" , "delay" and "repeat". Object is, the object number you want to animate, loop is what loop you want to use to animate it in the object's view number. Delay is how long you want the animation to be. Repeat is if you want the animation to repeat or not. If yes type in True. If no type in False. You can always add it before "ObjectOff (chest);"And "ObjectOn (chest);" and study it to see what makes sense, you will start getting it.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

rock_chick

I actually just got the conditional thing working before I read your replies but thanks anyway, I get the concept now that there needs to be conditions for both results. Also I was placing them in the wrong area and/or order but it seems to be working now I've fixed it up.
Also I will take up scripting eventually but not just yet.
Kat :)

SMF spam blocked by CleanTalk