Questions about room functions [SOLVED]

Started by Chrille, Mon 18/01/2010 19:45:53

Previous topic - Next topic

Chrille

I'm considering making my own system for interacting with hotspots/objects using a system of arrays & structs. Actually GarageGothic suggested this option to me ages ago but then the old ProcessClick system seemed managable and now it's getting in the way as the game grows. I can save alot of code and time if this is possible.

What I'd like to know is:

1) If there is some sort of global function that's called every time any room is loaded before fade-in, like the "room_load" function. I've been unable to find one.  I guess I could make my own function with my special conditions and just stick ChangeRoom at the end. But that would mean the special conditions would be executed in the old room. What would happen if ChangeRoom was placed at the top of the function, would the special conditions be executed in the new room? Curious!

2) I want to make my own interact function, called when the player clicks on something. What I'm unsure about is how I can call the function in the room when triggered from the global script. Something like this:

Code: ags
on mouse click -> is cursor over hotspot? -> interact (hotspot id);


so in the room it would look pretty much like this:
Code: ags
function interact {
// things happening
}


I guess the reason why I'm confused, wondering if this is even possible, is because it seems the regular ProcessClick actions aren't even registered unless it has been specified that a hotspot/object has an interaction in the room editor. So, I'd be very happy if someone could explain how this works!
GASPOP software
http://www.gaspop.com

Khris

1) You're looking for on_event.
http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm

2) In on_mouse_click, store the location ID using GetLocationType & X.GetAtScreenXY in a variable, then use CallRoomScript(location_type).
In the room_script, add

Code: ags
void on_call(int lt) {
  if (lt == eLocationHotspot) {
    if (global_ID_var == 1) {  // player clicked hotspot 1
      // process using mouse.Mode
    }
    else if
    ...
}

Chrille

Urgh! It was right there in text and I still couldn't find it. I guess I didn't know exactly what I was after. Thanks for looking it up for me ::)
GASPOP software
http://www.gaspop.com

SMF spam blocked by CleanTalk