Let's say i have two rooms, room1 and room2. There's a character in room1, let's call him Jake. I want it so that i can get an inventory item from hotspot 5 in room2 after i talk to Jake, i don't want it to be availible from the hotspot in room2 before i talk to him. Is this possible? By the way, i still want the hotspot in room2 to be activated before i talk to Jake, so that i can look at it and get a message.
The scenario is that the player is getting some ammo for a turret after he is asked to get it, if anyone is interested. It would be odd if i could complete the task before being asked, don't you think?
To quote the BFAQ:
QuoteNOTE: Please keep the following in mind. Most of our problems can be easily solved using variables. Need to change a hotspot's state in another room? Use variables! Need an object to be used only once? Use variables! You can either use Global Integers and Global Strings (look inside the AGS manual for these) or custom variables.
If you use GlobalInts, you can use the dialog script command
set-gloabalint to change it, otherwise you'll need to use
run-script and
dialog_request (See also: GlobalInts, your friends: What they are and how to use them (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#GlobalInts.2C_your_friend:_what_they_are_and_how_to_use_them), and Running regular code inside a dialog (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#Running_regular_code_inside_dialog).)
I tried to to the folowing:
I created an object in room3, ScriptOname oMadc. I set it to be invisible at the start. Then i configured Jake (in room2) so that the variable MADC AMMO was set to 2 (default was 1) after i talked to him. Then i entered the script editor for room3 and wrote the following:
// room script file
if (GetGraphicalVariable ("MADC ammo")==2)
{ oMadc.Visible }
But i just get a compile error when i try to save, "Error (line 2): Parse error: unexpected 'if'
What have i done wrong?
If that's all that's in the room script, I'm not surprised there's an error - variables can be declared outside of function, pretty much eveything else needs to be inside one. In this case, you'll need to put the code in a 'run script' interaction for 'Player enters room - before fadein'.
Ok, i put the following in 'run script' in 'Player enters room - before fadein':
// script for Room: Player enters screen (after fadein)
if (GetGraphicalVariable ("MADC ammo")==2)
{oMadc.Visible}
Now the compile error says that there is a parse error at 'oMadc'. :/
OK, my excuse is I'm about to go to bed, and my head is tired. The other thing:
oMadc.Visible
Should be:
oMadc.Visible = true;
You need to set the Visible property to 'true', and you need a ; at the end of the line
Thanks for your help, works like a charm now. :)
You might like the Other room module for doing stuff like that.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20650.0