change object description

Started by Volcan, Fri 03/03/2023 21:45:58

Previous topic - Next topic

Volcan

How to change object description?

I can change sprites from object but not the description.

Crimson Wizard

If you mean, Object.Name, this may only be changed at runtime since AGS 3.6.0.

In earlier versions the solution may be to use custom properties instead.
https://adventuregamestudio.github.io/ags-manual/CustomProperties.html

Volcan

I tried it and I got an error. Object.Name is read only.

Volcan

#3
I'd like to change description of the object.

Edit: I made mistake here. Please delete it.

Volcan

I'd like to change description of the object.


Crimson Wizard

#5
Quote from: Volcan on Fri 03/03/2023 22:09:15I tried it and I got an error. Object.Name is read only.

Which version of AGS exactly are you using? Object.Name is only available for change in 3.6.0.

In earlier versions you would need to use something else, like custom properties, or make your own variables in script to store object descriptions.

Volcan

#6
3.5.1

I guess I need to update my AGS Studio.

Edited: I noted in AGS main page, the last version is 3.5.1 patch 18.

Where can I find 3.6?

Crimson Wizard

#7
Quote from: Volcan on Fri 03/03/2023 23:02:483.5.1

I guess I need to update my AGS Studio.

You may, but you don't have to, if it's only this problem, there are solutions in 3.5.1 too which I mentioned, and maybe some others.

Quote from: Volcan on Fri 03/03/2023 23:02:48Edited: I noted in AGS main page, the last version is 3.5.1 patch 18.

Where can I find 3.6?

3.6.0 is still not final, it's a wip version. It's under "Other downloads & resources" on the page.
Also in this forum thread:
https://www.adventuregamestudio.co.uk/forums/ags-engine-editor-releases/ags-3-6-0-release-candidate-rc1/

Volcan

I tried with this code.

Code: ags
  object[0].Graphic = 84;
  object[0].GetTextProperty("book-one");
  object[0].SetTextProperty("book-one",text1);

But in the game, in the statusbar at the bottom of the screen still writes Book despites we see there's a coin on the counter not a book.



Crimson Wizard

Quote from: Volcan on Sat 04/03/2023 03:11:41But in the game, in the statusbar at the bottom of the screen still writes Book despites we see there's a coin on the counter not a book.

Well, of course, because it does not know that it should be using your custom property. You also need to change how the status bar displays the object names.

I don't know how do you that in your game, have you scripted the status bar yourself, or you are using some built-in behavior?

If custom property is supposed to be optional (not set for all the objects), then you could do this:
* check if custom property's text value is not empty;
* if it's empty, then use the object's Name;
* if it's not empty, then use the property's text.

Khris

Calling the text property "book-one" doesn't make much sense, it should be something like "label" or "dynamic name".

Anyway, assuming that you're using the default "@OVERHOTSPOT@" as the label text, you need to set it manually in repeatedly_execute:

Code: ags
  int lt = GetLocationType(mouse.x, mouse.y);
  String labelText = Game.GetLocationName(mouse.x, mouse.y), dynName;
  if (lt == eLocationHotspot) {
    Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
    dynName = h.GetTextProperty("label");
  }
  if (lt == eLocationObject) {
    Object *o = Object.GetAtScreenXY(mouse.x, mouse.y);
    dynName = o.GetTextProperty("label");
  }
  if (lt == eLocationCharacter) {
    Character *c = Character.GetAtScreenXY(mouse.x, mouse.y);
    dynName = c.GetTextProperty("label");
  }
  if (dynName.Length > 0) labelText = dynName;
  lblStatusBar.Text = labelText;

Also, line 2 from your snippet is completely pointless.

Matti

#11
As a sidenote, an easier workaround might be to use two objects. To me it seems that you change the book object's graphic to a coin (as part of a transaction). Instead you could just disable the book object and enable a coin object.

Also I advice you to use object names instead of their numbers, e.g. oBook.Graphic instead of object[0].Graphic. This makes your code more readable and mistakes less likely.




SMF spam blocked by CleanTalk