About making a dynamic name

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

About making a dynamic name

Post by Tdarcos »

I tried a suggestion. I defined a room without giving a name for it in the definition, then including a name property, like this:

Code: Select all

room warehouse_B 
{

   n_to warehouse_BN2
   s_to warehouse_BS2
   w_to warehouse_BW2
   e_to warehouse_BE2

   name
   {
     "Basement Control Center";
	 
      if (shutoff_power is not switchedon) or (electric_meter is broken)
          "\nEMERGENCY LIGHTING ACTIVATED";

   }
If I set the name property by a quoted string on the room definition and include a name property, the compiler gets uneasy and doesn't like it.


Doing this, if someone throws the power off, makes the system think that I've overflowed the screen and trips the routine to priint "[MORE]" and wait for a keypress. That doesn't make any sense, but that appears to be what it's doing.

I guess I will have to use the Dynname property I wrote up for the Wiki after all.

What I want is, every time the room is enterered or the user views the room, it gives the name of the room if the power is on, or gives the name of the room and a second line reading EMERGENCY POWER ACTIVATED to indicate this room has emergency power. Of course, there might be a before or after property I can set that would cause the system to do this then go on to the regular actions.
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

Roody_Yogurt
Posts: 2180
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

I didn't read what you said there all that closely, but I do know that the dynamic names like that have to be handled a bit differently. This should work:

Code: Select all

room warehouse_B
{

   n_to warehouse_BN2
   s_to warehouse_BS2
   w_to warehouse_BW2
   e_to warehouse_BE2

   name
   {
   if (shutoff_power is not switchedon) or (electric_meter is broken)
          return "Basement Control Center\nEMERGENCY LIGHTING ACTIVATED"
   else
          return "Basement Control Center"
   } 
The game is likely to still hate this, though, since PrintStatusLine, the routine for drawing the bar at the top of the screen, will set the status line height to 1 unless you go and replace it with something that'll make room for this.

Instead of doing that, you'd probably be better off with replacing DescribePlace and putting something to print "EMERGENCY LIGHTING ACTIVATED" under the right conditions.

User avatar
Ice Cream Jonsey
Posts: 28921
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

You could do this:

Code: Select all

room WarehouseB "Warehouse B"
{
}
So it has a default name, and then something like this when you turn the lights on and off:

(... this'd be in your light switch object)

Code: Select all

before DoSwitchOn
{
  location is light
  location.name = "Warehouse B (Emergency Power Active)"
  "Done."
}
before DoSwitchOff
{
 location is not light
 location.name = "Warehouse B
 "Done."
}
... the routine may be "DoSwitchedOff" instead of DoSwitchOff. It's DoSwitchSOMETHING. :)
the dark and gritty...Ice Cream Jonsey!

Roody_Yogurt
Posts: 2180
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

Yeah, there's that, too. I wasn't sure if Tdarcos really wanted the second message on a new line, as that complicates things.

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Roody_Yogurt wrote:I didn't read what you said there all that closely, but I do know that the dynamic names like that have to be handled a bit differently. This should work:

Code: Select all

          return "Basement Control Center\nEMERGENCY LIGHTING ACTIVATED"
Tried that. Fucks up the display and kicks in the "More" message.
Instead of doing that, you'd probably be better off with replacing DescribePlace and putting something to print "EMERGENCY LIGHTING ACTIVATED" under the right conditions.
Actually I just replace the one line in DescribePlace with it calling the optional property. I realize I like the solution I did because it leaves
Basement Control Center
in the status line, but shows
Basement Control Center
EMERGENCY LIGHTING ACTIVATED

When they look at the room (if the power is off.)
Last edited by Tdarcos on Tue Jan 03, 2012 9:34 am, edited 1 time in total.
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Ice Cream Jonsey wrote:You could do this:

Code: Select all

before DoSwitchOn
{
  location is light
  location.name = "Warehouse B (Emergency Power Active)"
  "Done."
}
I want the message to appear below the line, as it's an add on to the room as an emergency message. It's sort of like the woman in the emergency lights who says the same thing in Die Hard when the FBI cuts power to the building.
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

User avatar
Tdarcos
Posts: 9341
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Roody_Yogurt wrote:Yeah, there's that, too. I wasn't sure if Tdarcos really wanted the second message on a new line, as that complicates things.
I do want the room name to be two lines when the person re-enters the room or when they do a "look" command.
"I really feel that I'm losin' my best friend
I can't believe this could be the end."
- No Doubt, Don't Speak

Post Reply