calling an object to a different room

Started by Jojowl80, Tue 21/07/2020 05:21:45

Previous topic - Next topic

Jojowl80

I have this in my Global script, its an item the player can click on, and the idea is I want a bunch of stickers to show up as they collect them throughout the game.

Code: ags


function iStickersheet_Interact()
{
if (sticker_1 == true) {
object[0].Visible = true;  
player.Transparency = 100;
gMain.Visible = false;
gAction.Visible = false;
player.ChangeRoom(33);
 }  
 
  else {
player.Transparency = 100;
gMain.Visible = false;
gAction.Visible = false;
player.ChangeRoom(33);

 }
}


I made a Bool for sticker_1 and I also set the bool to true when the item was collected.
however it does not seem it is calling the object at all. Maybe it is calling it to a different place?

Gilbert

I don't know whether I get what you want to do, but remember that objects are local to rooms, so when you set the visibility of object[0] to true, it will set the visibility of whatever object #0 is for the room the player is currently in.
If you want object #0 to appear in room 33 instead, try to do so in the 'enter room' event of that room to set the visibility of the object by checking the value of sticker_1.

Or, if what you want is to display the object to appear in ALL the rooms you should not use an object (as objects are local to rooms), use a GUI or a character (that follows the player to change room) instead to depict the item.

Khris

#2
If you implement the close up of the sticker sheet as a GUI, you can use buttons to show the stickers. Since buttons are global, you can simply set them visible when the player is picking up the item, no need for variables.

(Also note that an additional issue with your current code is that only line 5 should depend on the condition in line 4, while lines 6-9 should always run because they're about displaying the sticker sheet and have nothing to do with sticker #1 directly. There's no need for that else block at all.)

Jojowl80

I guess I can make a GUI if I have to, but is there anyway to call it when I use the "usermode" function?

Crimson Wizard

Quote from: Jojowl80 on Tue 21/07/2020 18:21:19
I guess I can make a GUI if I have to, but is there anyway to call it when I use the "usermode" function?

You may test current mouse mouse in GUI's OnClick event and only proceed if right mode is on.

Code: ags

if (mouse.Mode == eSomeMode)
{
}

Jojowl80

I ended up just making a GUI. thanks everyone!

SMF spam blocked by CleanTalk