Object.Clickable delayed? [SOLVED]

Started by iamlowlikeyou, Fri 28/01/2011 16:28:34

Previous topic - Next topic

iamlowlikeyou

Player enters a room right next to an object (while setup to detect nearby objects and then write name of object to a label) - I put in function room_Load():
Object.Clickable = false;

Yet player detects the object for about 1 second, before it disappears.
I can't get this to make sense, as the room_Load() function should happen before fade-in, and thus long before player gets there?

Ryan Timothy B

#1
How exactly does the "player detects the object"? And what do you mean by "while setup to detect nearby objects and then write name of object to a label"? Are you checking around the player for objects and their names?

room_load is called after the on_event BeforeFadeIn.

Where is this script located that checks the nearby objects and their names?

Also you said "before it disappears", I hope you meant: before the text disappears.

iamlowlikeyou

Khris wrote a module for me, that somehow gets all objects, hotspots and characters, and then display their names on a GUI label, if player is standing so and so in relation to them. Don't ask me how it works, it just does  ;)
Anyway, that's not what's important. The thing is that either the Object.Clickable or the room_Load is delayed... Room_Load is said to happen before fade-in, that's why I don't understand why the function is carried out AFTER fade-in...?

And yes, I meant before the TEXT disappears, not the object  ::)

Ryan Timothy B

Is this module that Khris wrote on the forums? That way we can look at it and find out when it grabs the names of Objects, etc.
Otherwise we'll just be pulling random guesses out of our scripting hats. :P

iamlowlikeyou

If you need it I can post the entire script here - I wouldn't really know which parts to draw out, as I don't understand the script entirely myself.

But I'll just ask first;
when you usually make an object unclickable, where do you put the Object.Clickable = false line?
I mean, is it in the room script, or is there some way to do it from the main script, like when the game starts?
(I wouldn't think so, as objects are room-specific, but you never know :))

Khris

Since there were problems with room changes I added on_event to the module, in there, the hotspot locations are updated. And because the module's on_event(eEventBeforeFadein) runs before the room's room_Load, the module picks up the object. The next update is only 20 game loops i.e. half a second later, thus the object is picked up.

Open NoMouse.ash and add this line:
Code: ags
import void InitRoom();


Then put
Code: ags
  InitRoom();

after the line that sets the object not clickable.

iamlowlikeyou

Thanks, Khris!
I didn't think it had anything to do with the module...
It's working fine now.

SMF spam blocked by CleanTalk