Page 1 of 1
Unwanted periods
Posted: Mon Sep 05, 2011 6:54 pm
by Bainespal
This is a small aesthetic problem, but I can't solve it on my own. I have two rooms in my game that need to display different names depending on certain conditions. In both cases, my code works as expected except that it puts a period after the room title in both the status line and the main window. I have no idea where the period is coming from, and it doesn't matter whether or not I use "print" or just have a double-quoted string.
Here's an example of the code (using different strings than in my game):
Code: Select all
room hillside
{
name
{
if night_flag = true
{ "A Shadowy Incline"; }
else
{ "A Sunny Hillside"; }
}
}
The game would print "A Shadowy Incline." or "A Sunny Hillside."
Posted: Tue Sep 06, 2011 2:24 am
by Roody_Yogurt
This took some looking into, but eventually I found the answer in the Pirate Adventure source. You want this:
Code: Select all
room hillside
{
name
{
if night_flag = true
return "A Shadowy Incline"
else
return "A Sunny Hillside"
}
}
Personally, I'm a little unclear on what are the rules about returning strings from object properties. The other day, I was unsuccessfully trying to return a printed string from a cant_go property or something, so I share your confusion.
My only guess is that since object.name isn't treated like a regular string, wackiness ensues.
EDIT: I have updated the HxE page to reflect this:
http://hugo.gerynarsabode.org/index.php?title=Name
Posted: Tue Sep 06, 2011 5:59 am
by Bainespal
Wow... I'm surprised that this little bug is such an obscure problem.
Roody_Yogurt wrote:The other day, I was unsuccessfully trying to return a printed string from a cant_go property or something, so I share your confusion.
That's also good to know. If I have to have a conditional can't-go message (which I'm contemplating at the moment), I won't bother putting the condition in a cant_go property; I'll trap it in "location DoGo" instead.
Thanks for doing all the digging. It's surely a good thing that this is being documented in HxE.
Posted: Tue Sep 06, 2011 10:21 am
by Roody_Yogurt
Well, you still can do this:
Code: Select all
cant_go {
if object = se_obj, s_obj
{
"That'd put you in the lake!"
return true
}
elseif object = e_obj
{
"There's a brick wall there."
return true
}
else
return false
}
I just was unsuccesful trying things like 'return "There's a brick wall there."'