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 !
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".
thanks for speed-answer !!
i want change visibility of an object in an room
es :
ochair.visible = true
ochair is not recognize
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.
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.
Objects are related to the rooms they're in so you can only modify them in the room's script..
ok , if you are sure of this limitation, it's ok for me
thanks and best regards
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;
}
}
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
To me, that sounds like the sort of thing you should be doing with a GUI or an overlay, not room objects.
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;