Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: indianajo2 on Sat 16/08/2008 14:39:42

Title: object property access form global script
Post by: indianajo2 on Sat 16/08/2008 14:39:42
hello , I have  a little problem :

in which mode I can modify  the object's property  in a  room  from global script ?

Ags debug  return  this : objectname = token not recognized

thanks !

Title: Re: object property access form global script
Post by: Khris on Sat 16/08/2008 14:52:31
What property are you referring to, exactly? .Name?

As stated in the manual, Object.Name is read-only, meaning it can't be changed in-game.
Also mind the capitalization and correct usage, writing "Object.Name" won't work, unless the object's scriptname actually is "Object", which you shouldn't use as name, if that's even possible.

If your object is called "Ball" you can read its name using "Ball.Name".
Title: Re: object property access form global script
Post by: indianajo2 on Sat 16/08/2008 14:54:33
thanks for speed-answer !!


i want change visibility of an object in an room

es :   

ochair.visible = true


ochair   is not recognize
Title: Re: object property access form global script
Post by: Khris on Sat 16/08/2008 14:59:51
Select the object, then enter the desired scriptname into the Name field in its properties list.
Also, once more, mind the capitalization, it's ".Visible", not ".visible".
If you save the room after entering the object's scriptname, then open the room script, AGS will recognize the name as soon as you've typed the first three letters.
Title: Re: object property access form global script
Post by: indianajo2 on Sat 16/08/2008 15:05:15
ok, thnks, I try your system.

but...

Are you fine  understand my problem?


I can't   modify object property  only if  I write line code in global.asc  ok?

If I try to modify object property in room script , all is ok.


excuse , I am italian and my english is bad.
Title: Re: object property access form global script
Post by: Matti on Sat 16/08/2008 15:08:46
Objects are related to the rooms they're in so you can only modify them in the room's script..
Title: Re: object property access form global script
Post by: indianajo2 on Sat 16/08/2008 15:26:05
ok , if you are sure of this limitation, it's ok for me


thanks and best regards
Title: Re: object property access form global script
Post by: monkey0506 on Sat 16/08/2008 15:29:06
As matti said, objects are room-specific, but you could do something like:

if (player.Room == 5) { // whatever room oChair is in
 object[8].Visible = false; // whatever object number oChair is
}


You can't use the object's script o-name at all, you can only reference the object by its ID, but it is possible to do this from the global script. But this does beg the question, why do you need to do it from the global script instead of the room script?

Another alternative would be something like this:

// global script
CallRoomScript(1);

// room script
function on_call(int script) { // you probably have to create this function in the room script yourself, unless you're already using it
 if (script == 1) {
   oChair.Visible = false;
 }
}
Title: Re: object property access form global script
Post by: indianajo2 on Sat 16/08/2008 15:41:07
my scope is simple :


when the mouse  goes on every object in every  room, I want that another object (like a little bulb or led ) is visible.  when the mouse is out from every object in  every room , the bulb/led must  return not visible.

in summary, is only a little help in every room for in/out objects  mouse position
Title: Re: object property access form global script
Post by: Makeout Patrol on Sat 16/08/2008 18:37:15
To me, that sounds like the sort of thing you should be doing with a GUI or an overlay, not room objects.
Title: Re: object property access form global script
Post by: Khris on Sat 16/08/2008 21:54:55
Yes, create a GUI (visibility: normal) with the bulb sprite as background image and name it gBulb.

Then, in the global script inside the repeatedly_execute function, put
  if (GetLocationName(mouse.x, mouse.y) != eLocationNothing) gBulb.Visible = true;
  else gBulb.Visible = false;