I have a problem with getting an object to show up in a room after a dialogue

Started by sgt. Pepper, Sun 07/05/2006 00:30:20

Previous topic - Next topic

sgt. Pepper

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?

Ashen

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, and Running regular code inside a dialog.)
I know what you're thinking ... Don't think that.

sgt. Pepper

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?

Ashen

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'.
I know what you're thinking ... Don't think that.

sgt. Pepper

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'.    :/

Ashen

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
I know what you're thinking ... Don't think that.



SMF spam blocked by CleanTalk