Hugo -- illegal semicolons/undefined properties

I must be making a very amateur mistake in the first complicated object that I started to implement in the Hugo game which I recently began writing. I can’t see what I’m doing wrong.

First of all, here’s the entire object definition, with the text deleted. It’s supposed to be a bed that can be recessed into the wall in order to save space. When recessed, it’s considered “not open.”

object bed "..." { in startroom is static noun "...", "..." adjective "..." pronoun "..." long_desc { "...bulk of description..."; if self is open print "..."; else print "..."; print " ... "; if self is open print "... "; else print "... "; print "... "; if self is open print "..."; else print "..."; print "." } short_desc { "...first part of description... "; if self is open "..."; else "..."; print "." } }

When I compile the above code, I get an error complaining of an illegal semicolon on the line containing the last “else print” statement in the long_desc:

if self is open print "..."; ! No period at end of sentence else print "..."; ! No period at end of sentence print "."

I can change these lines to get rid of the semicolons on the first two print statements and remove the last one by printing the period at the end of both of the other two statements instead of at the end of the code block by itself:

if self is open print "..." ! Period at end of sentence else print "..." ! Period at end of sentence

This gives me a different error, “Undefined property,” at the last line of the object definition (containing only the closing brace), which is also the last line of the source file.

I tried enclosing all of the conditional statements in braces, but that didn’t work, either.

Thanks! I hope you all had a good Christmas yesterday. :slight_smile:

I was able to get this to compile:

[code]
object testbed “…”
{
in startroom
is static
noun “…”, “…”
adjective “…”
pronoun “…”
long_desc
{
“…bulk of description…”;

if self is open 
{
	print "..."; 
}
else 
{
	print "...";
}
 print " ... ";

if self is open 
{
	print "... "; 
}
else 
{
	print "... ";
}
 print "... ";

 if self is open 
 {
print "...";
 }
 else 
 {
print "...";
 }
 print "."

}

short_desc
{
"…first part of description… ";
if self is open
“…”;
else
“…”;
print “.”
}
}[/code]

Do you get the undefined property error if you remove the definition for the bed completely? It may be an issue with something other than the bed, and it’s just telling you that it’s on the last line because everything else got compiled OK.

The bed object was indeed the problem, and now that I followed your outline, it compiles fine. :smiley: I deeply appreciate the effort you took to go through my sloppy code line by line. I didn’t expect someone to step in and offer help so soon and so thoroughly.

I’m going to have to get in the habit of putting every piece of code between braces. I learned by experimentation that braces may enclose the text string of a long_desc, but they don’t have to. I imagine that there must be other cases where the braces aren’t strictly needed but will still compile. It will probably be better for me just to use them all the time.

Cool - glad that worked for you!