Changing object name [worked around]

Started by WHAM, Sun 24/01/2010 21:46:51

Previous topic - Next topic

WHAM

Is there no way to change an object's name in-game?

When I try to do something like:
Code: ags

oCar.Name = "wreck";


I get an error saying that the object's name is a read only value. Puh-leeeeze tell me there is a way around this!
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Ryan Timothy B

#1
Well yes, there is.  But making an object with the name "Wreck" to just replace the object with the name "Car", would be much easier.
But if I really needed to do this, without having to make multiple objects or hotspots with different names I would do this:




Instead of having the Label in your GUI with the text @OVERHOTSPOT@  do this in your rep_ex  or  rep_ex_always (depending if you want hotspots to be checked during blocking moments):
Code: ags

  //Global Script
  Label1.Text=Game.GetLocationName(mouse.x, mouse.y);  //this does the same as  @OVERHOTSPOT@

  //Room Script
  if (Label1.Text=="Car") Label1.Text="Wreck";


Obviously, you'd have to have a boolean to set whether the car is damaged or not, and needs the new name.

Edit: Actually it would be even better if you did this:
Code: ags

  if (Label1.Text==oCar.Name) Label1.Text="Wreck";

WHAM

Quote from: Ryan Timothy on Sun 24/01/2010 22:17:14
Edit: Actually it would be even better if you did this:
Code: ags

  if (Label1.Text==oCar.Name) Label1.Text="Wreck";


Of course! Why must I be so blind!? Thank you Timothy, for helping me find the little things I should've realized myself in the first place! =)
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

SMF spam blocked by CleanTalk