Hey, thanks for catching that error. It looks like I was trying hard to do dynamic names without adding to the dictionary table, and as you've pointed out, that looks like a really bad idea.
I think, in both cases, we're going to want to use the dict command to add new strings to the dictionary table during game play.
First thing in your source, you need to raise your MAXDICTEXTEND limit:
How much you raise it depends on how many possible strings (and their lengths) there are. You need a bit open for every letter and one for the empty bit finishing off each string. So, if you're making space for five strings with an (exact) average of 10 letters, you'd need to to set $MAXDICTEXTEND to 55.
Now, this is how I'd do the dynamic street name thing:
Code: Select all
property street_number alias misc
player_character you "you"
{
before
{
actor MovePlayer
{
! _temp_string is a temporary string array defined by hugolib.h
! the "text to" command writes to it
text to _temp_string
if object.street_number < 1
print "East ";
else: print "West ";
print number abs(object.street_number);
print ordinal( object.street_number ) ;" St.";
text to 0 ! stop writing to the string
object.name = dict(_temp_string,100)
return false
}
}
}
! not the original ordinal routine. just something to print something.
routine ordinal(street_num)
{
print "st";
}
! this will end up being "West 1st street"
room startlocation
{
street_number 1
e_to east_room
}
! this will end up being "East 1st Street"
room east_room
{
street_number -1
w_to startlocation
}
Now, the nice thing about dict is that when the above code is run for a second time on a room, it'll return the same address as it did before so you don't have to worry about using up all of your dictionary table space on the same objects.
Maybe you can do the same thing for your problem.