So when the cursor is over something, it will display its name. But not the description; I need to do it with a property called "name" or whatever. Because in spanish, you can't say "a shoe" or "a woman". You say EL and LA depending if it's masculine or femenine, so I need the description be like "la mujer", "el zapato", while the description just say "Mujer" and "Zapato". Hope you understood, I can't figure how to do it.
Sorry, what? Why can't you put "Una mujer" in the description field if you want to display that?
Is there a technical reason you can't set the "el"/"la" in the editor? You already said you're using a property for the name...
Anyway, I guess if I was to do it then I might do something such as:
String GetPrefix(String word) { // get just the prefix for each word
if (word == "mujer") return "la";
if (word == "zapato") return "el";
if (word == "boligrafo") return "el";
if (word == "lapiz") return "la";
// ...
return ""; // word not found, return an empty string
}
String GetWordWithPrefix(String word) {
if (String.IsNullOrEmpty(word)) return ""; // if an invalid string was given, return an empty string
String prefix = GetPrefix(word); // get the word prefix
if (prefix.Length > 0) prefix = prefix.Append(" "); // if there was a prefix given, add a space
return prefix.Append(word); // return the word with the prefix
}
Then you could do something like:
lblDescription.Text = GetWordWithPrefix(Game.GetLocationName(mouse.x, mouse.y));
You don't get it because it's something with my language. Let me try to explain it better.
Let's use 2 common examples:
Mujer = woman in spanish
Hombre = man in spanish
In english you just say "a woman" and "a man" so you can put just "man" in the description, and then the character will say "that's a man" and when the cursor is around the man, it will show just "man".
Well, in spanish, the character should say "that's LA MUJER" and "that's EL HOMBRE". It's like a prefix, depending if the thing is masculine or feminine. So, when the character looks at the man, he must say: "that's EL HOMBRE". If I put "el hombre" as the description name, when the mouse is over the man, it will display "el hombre", while I want it to just display "hombre".
The solution to this, is to have a property called name, where I can put the name of the things without the LA o EL prefix. Then when the mouse is over the character or hotspot, it will display what's written on the property.
Hope it clears things up, it's really hard to explain if you don't speak spanish.
Why can't you put just "HOMBRE" as character name, and simply add article in character speech?
Or are you trying to make some generic "look at" interaction handler?
So you don't want the el/la on the label, but just when the player is saying what it is, right? So basically:
- Do not put the el/la as part of the name in the editor at all.
- Use something like this for your code:
String GetPrefix(String word) { // get just the prefix for each word
if (word == "mujer") return "la";
if (word == "zapato") return "el";
if (word == "boligrafo") return "el";
if (word == "lapiz") return "la";
// ...
return ""; // word not found, return an empty string
}
String GetWordWithPrefix(String word) {
if (String.IsNullOrEmpty(word)) return ""; // if an invalid string was given, return an empty string
String prefix = GetPrefix(word); // get the word prefix
if (prefix.Length > 0) prefix = prefix.Append(" "); // if there was a prefix given, add a space
return prefix.Append(word); // return the word with the prefix
}
function unhandled_event(int what, int type) {
if (((what == 1) && (type == 1)) || (((what == 2) || (what == 3) || (what == 5)) && (type == 0))) {
player.Say("Es %s.", GetWordWithPrefix(Game.GetLocationName(mouse.x, mouse.y)));
}
}
Or add a Custom property, "female", boolean, default false. Then check it for all female hotspots.
The downside is that you have to use GetLocationType, then Hotspot/Object/Character.GetProperty.
Well if you're going for the custom properties route, wouldn't it be better to have a text property then?
Something like "prefix" default value "" (an empty string) that could be set for every character/object/hotspot/inventory item in the game. And then you could have a function such as:
String GetPrefixAtScreenXY(int x, int y) {
if ((x < 0) || (x >= System.ViewportWidth) || (y < 0) || (y >= System.ViewportHeight)) return "";
Character *cat = Character.GetAtScreenXY(x, y);
Hotspot *hat = Hotspot.GetAtScreenXY(x, y);
InventoryItem *iat = InventoryItem.GetAtScreenXY(x, y);
Object *oat = Object.GetAtScreenXY(x, y);
LocationType type = GetLocationType();
if ((type == eLocationCharacter) && (cat != null)) return cat.GetTextProperty("prefix");
else if ((type == eLocationHotspot) && (hat != null)) return hat.GetTextProperty("prefix");
else if ((type == eLocationObject) && (oat != null)) return oat.GetTextProperty("prefix");
else if (iat != null) return iat.GetTextProperty("prefix");
return "";
}
// in unhandled_event
player.Say("Es %s.", GetPrefixAtScreenXY(mouse.x, mouse.y));