Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: fiaschetta on Sat 29/04/2006 03:24:30

Title: ObjectON in another room
Post by: fiaschetta on Sat 29/04/2006 03:24:30
I stay in room 4... I want that after a dialog with a charcather in room 4, the object (3) of the room 2 become visible..
How i do?
Title: Re: ObjectON in another room
Post by: Ashen on Sat 29/04/2006 13:14:29
1) (as I said in another thread of yours (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26313.0), in a vague way) Use variables. In the dialog change a variable value -you can do this directly, using GlobalInts, and the dialog script command set-globalint, or use your own int, and the run-script command (here's a list of dialog script commands (http://www.adventuregamestudio.co.uk/manual/Conversations.htm), or do a forum search if you want more detail on run-script, it's explained in a few threads). Then, when you enter room 4, check that variable's value and turn the object on if needed. If it's an object the player can then take from the room, don't forget to change the variable back when they do, or it'll be turned on again when they re-enter the room.

2) (as strazer said in that other thread) If you're going to be doing a lot of manipulating objects, hotspots, etc in other rooms, you might find his OtherRoom module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20650) usefull, as it takes care of all the variables for you.
Title: Re: ObjectON in another room
Post by: fiaschetta on Sat 29/04/2006 16:09:28
Well.

In script of dialog:

@1
EGO: Ciao!
run-script 2
stop

then in global script (i used the OTHEROOM MODULE):

function dialog_request (2)  \lbraceraw
OtherRoom.ObjectOn (3,3);
\rbraceraw
{


But when i test game have an error of: ERROR : Parse error at '2'

Why?
Title: Re: ObjectON in another room
Post by: Ashen on Sat 29/04/2006 16:16:15
(I'm assuming the brace errors - e.g. \lbraceraw instead of { -  are just how it's copied, and they're OK in the script itself.)

Because you've declared the dialog_request function wrong. Do a forums search, or read the BFAQ entry (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#Running_regular_code_inside_dialog) to find more details. It should look like:

function dialog_request (int param)  {
  if (param = 2) {
    OtherRoom.ObjectOn (3,3);
  }
}
Title: Re: ObjectON in another room
Post by: fiaschetta on Sat 29/04/2006 16:24:55
Ok, but when i test game go out this error:

objecton is not a pubblic member of 'otheroom'
Title: Re: ObjectON in another room
Post by: Ashen on Sat 29/04/2006 17:52:43
Well, at least the run-script part seems to be working now.

That looks like it's an error either with the module itself, or with how you've set it up. I'm not actually familar with that module - are you sure you've got the function name (ObjectOn) right? (I just copied what you had, not sure if that's what it's actually called.) Also, check capitialisation (ObjectOn, vs Objecton, objecton, objectOn, etc).

EDIT: OK, just checked the module's readme. The function is OtherRoom.Object_On with an underscore, and should appear in the autocomplete - so provided you don't just copy-paste code without checking it, you should be OK.