Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: viktor on Sun 03/01/2021 16:08:35

Title: (SOLVED) Make object appear after interaction with character
Post by: viktor on Sun 03/01/2021 16:08:35
I'm having some issue getting this to work. I am aware what the issue is (I think). How can I make an object visible after a certain interaction with a character? If I am correct the error happens because this part of the interaction is in the global script and the object is part of the room script. So is it possible to even do this? In my example you hand over some money and a ring appears in another part of the room.

If I try it like in the code below, I get this error:

GlobalScript.asc(683): Error (line 683): Undefined token 'oRing'

Code (ags) Select
  // GIVE TO
  if (Verbs.UsedAction(eGA_GiveTo)) {
    if (player.ActiveInventory==iMoney){
      player.LoseInventory(iMoney);
      Wait(20);
      oRing.Visible=true;
    }
    else {
    player.Say("I don't think I want to bother her with that.");
    }
Title: Re: Make object appear after interaction with character
Post by: Cassiebsg on Sun 03/01/2021 16:15:20
object[ID].Visible=true;

If you are in the same room where the object should become visible, then just use the object ID. Otherwise you'll need a variable to check for when you load the room.
Title: Re: Make object appear after interaction with character
Post by: Crimson Wizard on Sun 03/01/2021 17:33:17
Another alternative is to use CallRoomScript (https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html#callroomscript) to trigger event in room script, where you may handle this. But that is usually suggested when similar action may be performed in multiple rooms.
Title: Re: Make object appear after interaction with character
Post by: viktor on Mon 04/01/2021 05:49:20
Quote from: Cassiebsg on Sun 03/01/2021 16:15:20
object[ID].Visible=true;

If you are in the same room where the object should become visible, then just use the object ID. Otherwise you'll need a variable to check for when you load the room.

Ah, OK. So you use ID's when not in the room script file. Thank you.