(SOLVED) Make object appear after interaction with character

Started by viktor, Sun 03/01/2021 16:08:35

Previous topic - Next topic

viktor

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
  // 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.");
    }
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

Cassiebsg

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.
There are those who believe that life here began out there...

Crimson Wizard

Another alternative is to use 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.

viktor

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.
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

SMF spam blocked by CleanTalk