Interact, once.

Started by Peefy, Mon 21/06/2004 15:34:46

Previous topic - Next topic

Peefy

Hi there!
In my game, the main character has to interact with a hotspot to get an item. What I wonder, is how can I get the interaction to change after one interact, like, replace the previous interaction with "There's nothing in there".
I looked quick in the manual and searched the knowledge base witout any luck,
so I asked on the chat, and they gave me 2 sollutions.
One that had some coding in it, setting an variable and such. I tried this, but because I'm new to AGS, I didn't fully understand it (and the one who said it left, so I didn't get to ask him aobut it).
The other one was to have two hotspots on the same location, and when the hotspot which gave the player an item, it disabled itself leaving the other one to be the "main-hotspot".
I tired that other method too, but it wont work.
I have se the hotspot to disable itself after giving the player the items and such, but when I interact agian, it still wont work =\

Thanks for reading, and thanks on advance for replies =D

viktor

well you could disable the hotspot. But then you wouldn't be able to interact with the   hotspot again (look, talk)
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

Kinoko

If it were me, I'd probably use GlobalInts.

Try a script like this in the 'pick up' interaction editor of the hotspot:

If (GetglobalInt(1) == 1) {
DisplaySpeech (EGO, "There's nothing in there");
}

else {

//The normal 'pick up' script here

SetGlobalInt(1) = 1;
}

If I'm wrong, someone correct me. I'm so very close to falling asleep right now but as far as I'm aware, this should work ^_^

If not, post your script here and I or someone else will be able to help.

Peefy

Viktor:
But I tried that, adn had an other hotspot underneath, but it wouldn't disable..

Kinoko:
Hm.. Atleast it looks advanced :P
But I don't have a pickup script.. as you state..
I asume you mean in the "Interaction editor" that I should add a script in "interact hotspot"..
Am I wrong?
But then, do you meant aht I should have the first part of the code beforethe pickup thing, and the second after?
Sorry, I'm new.  :D
Thanks again!

Kinoko

Sorry, I should've explained in a bit more detail.

OK, when you go to the interaction editor for that particular hotspot, double click on "pick up hotspot" (So if the player "picks up" the hotspot, he will get the item in the hotspot - I'm assuming that's what you want the player to do to get the item). From there, select "run script" from the drop down box and click okay.

Now you should be faced with a relatively blank script. Let's say that the item you want the player to pick up is number 5. A basic script would be:

If (GetglobalInt(1) == 1) {
DisplaySpeech (EGO, "There's nothing in there");
}

else {

AddInventory(5);
SetGlobalInt(1) = 1;
}


This is basically saying that the first time the player goes to pick up the hotspot, they will get inventory item number 5 (change that number to whatever your inventory item is). If they go to pick up the hotspot again, they will get the "There's nothing in there." line.

More specifically, once they've picked up the item, GlobalInt number 1 gets changed to equal 1 (by default, it's 0). Once it equals 1, it will give you the message.

Peefy

Thanks for so quick answer!
I copied and pasted the code, but no I get the error:
Error (line 14): wrong number of paraments in 'SetGlobalInt'

LordHart

#6
It should be:

SetGlobalInt(X, Y);

This way it will set the global int (which the X), to whatever you want it set to (in this case Y)... all you have to do is change X and Y to whatever your global int is and then the number you want it set to...

So for the script Kinoko set (correction in red):

If (GetglobalInt(1) == 1) {
DisplaySpeech (EGO, "There's nothing in there");
}
else {
AddInventory(5);
SetGlobalInt(1, 1);
}

That should do it... ;)

You could of also had it check to see if the character had the inventory item... where the code would be:

If (character[EGO].inv  == 5) {
DisplaySpeech (EGO, "There's nothing in there.");
}
else {
AddInventory(5);
}

Peefy

Thank you! :D
Should I edit my first post to that thumbs-up thing now?

LordHart

If it's working, then you can... ;)

Kinoko

Ah, whoops! I told you I was tired. Yeah, you could also use the "If inventory item" way as well, but if you go to use that at sme point, keep in mind that if you end up using the inventory item somewhere (thus ridding yourself of it), the hotspot will continue to give you the item again... which is unlikely to make sense in the game.

Then again, there are people who prefer not to use GlobalInts too. I'm not entirely sure why so I won't go into it :)

SMF spam blocked by CleanTalk