FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

name property

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
fleagor
Guest





PostPosted: Tue Dec 14, 2004 11:33 pm    Post subject: name property Reply with quote

Hello,

I apologize if any of this doesn't come across cleanly or clearly, this is my first time posting to one of these boards. I had a question about the behavior of the "name" property for rooms and objects, and this is using Hugo v3.1.01. Normally I would do this (and please bare with me):
Code:
room testroom "test room"
{
   long_desc
   {
      " You are surrounded by unfinished code.
      Obviously whoever did this has no idea
      what he's doing."
   }
}


But assuming that I had gone temporarily mad and wanted to do it this way:

Code:
room testroom
{
   name
   {
      "test room"
   }
   long_desc
   {
      " You are surrounded by unfinished code.
      Obviously whoever did this has no idea
      what he's doing."
   }
}


so that I could use different color properties, or if I went off the deep end and wanted a switch statement to randomize room names, or whatever, I run into a problem.

Instead of this:

Test room
You are surround by unfinished code, etc.

I get this:

Test room
.

You are surround by unfinished code, etc.

So in the second example I get a newline followed by a period, still bold. The status line displays "MORE..." then after pressing Enter, displays the aforementioned period as the room name.

How can I avoid the addition of that period and the "MORE..." issue?

I noticed a different situation when I tried to use the name property in a similar way on a plain object, but hopefully the answer to how to fix this will also apply to that. Otherwise I can relate that one as well.

Also, for future additions/changes to Hugo, how about adding a "color" formatting sequence to embed in printed strings? Something like
Code:
\C(foreground,background)
So you could do \C(RED,BLACK) right in the middle of a line, you know, to cause eyestrain and irritation. I imagine it could have applications for the forces of good as well. Also, I'd like to vote for png support as an addition. I saw that one mentioned in another post.

Thanks,

fleagor
Back to top
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Wed Dec 15, 2004 2:01 am    Post subject: Reply with quote

I am not sure about the color thing, but I had a similar concern with names being appropriate and not appropriate for characters.

I had one character I wanted to turn into a ghost, but I didn't want that character to be able to be called a ghost until the time was right. The solution was this for starters:

Code:


female_character Sydney "Sydney"
{
  charnumber 10
  maxhitpoints 100

  nouns "jessica" "" "" "" "drieden" "girl" "blond" "blonde" "jess"
  adjectives "jessica" "jess"
}


The odd part is putting the "" characters there. What that does is essentially placehold so that later I can add the word "ghost" and "spirit" there. I was able to do that by putting

Code:


Jessica.noun #2 = "ghost"
Jessica.noun #3 = "spirit"



In a routine that got called when the character changed.

Can this same principle work for room names?!!? I just happen to have the barebones of a new Hugo game going in another window, so I'm-a-gonna try it and I'll get right back to you in this thread with what I find.
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Wed Dec 15, 2004 2:10 am    Post subject: Reply with quote

OK, this should work:

1) Setup your room as follows:

Code:
room testroom ""
{

   long_desc
   {
      " You are surrounded by unfinished code.
      Obviously whoever did this has no idea
      what he's doing."
   }
}


And then set up a routine to give it a name. (You mentioned that you wanted it to randomize the room name, for instance.)

Code:

routine RandomizeRoomName
{
  local x

  x= random(3)

  select(x)

  case 1
  {
     testroom.name #1 = "TestRoom1"
  }     

  case 2
  {
     testroom.name #1 = "TestRoom2"
  }

  case 3
  {
     testroom.name #1 = "TestRoom3"
  }
}


I think that should work for getting random names for your room in there.


--Robb
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Wed Dec 15, 2004 2:44 am    Post subject: Reply with quote

Speaking just to the original post, if I have this:

Code:
room testroom
{
   name "test room"

   long_desc
   {
      " You are surrounded by unfinished code.
      Obviously whoever did this has no idea
      what he's doing."
   }
}


it works fine. Note the only difference is I did not include { } characters around the name property.

Further, I could then do something like this:

Code:
room testroom
{
   name "test room"

   long_desc
   {
      " You are surrounded by unfinished code.
      Obviously whoever did this has no idea
      what he's doing."
   }

   before
   {
      location DoSmell
      {
         testroom.name = "smelly test room"
      }
   }
}


Now if I type "smell" in the room, the name of the room will be changed to "smelly test room". Of course, you could also call a routine and do any randomizing you wanted.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
fleagor
Guest





PostPosted: Wed Dec 15, 2004 12:12 pm    Post subject: more name mayhem Reply with quote

Wow, thanks for the fast replies! After looking at both your responses I thought I would try the sure-fire method for triggering the random room name routine, and by gods it worked!

As an added bonus, you guys pointing me toward routines showed me the way to do differently colored room titles. I'm sure it isn't the prettiest way, and maybe something could be done to make it easier to apply to an entire world, but I don't really know programming.
Code:
room testroom ""
{
   long_desc
   {
      color DEF_FOREGROUND
      "Here lie words."
   }
   before
   {
      location DoLookAround
      {
         color YELLOW
         return RandomizeRoomName
      }
   }
}

A random room name every time you look, and in vibrant yellow! Thanks for the help.

I also found that I could replace the room class with a version that contains the before routine above so that I could have every title of every room in the same color, and handled all automatic for me, but I still had to insert a "color DEF_FOREGROUND" at the beginning of each long_desc to bring it back to the normal color.

I tried inserting
Code:
long_desc
   {
      color DEF_FOREGROUND
      ""
   }
}

into my new room class but it didn't catch the color call.
If you see a better or cleaner way to do this, or any other feedback/ideas, I'd appreciate it.

fleagor
Back to top
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Wed Dec 15, 2004 12:48 pm    Post subject: Reply with quote

Wouldn't that only make the title color yellow when you look? If you enter the room for the first time, that code shouldn't even run... You would need to add an each_turn { } section to the room, remember what the last room was, and then run the code if the last room changed *or* if the "lookaround" verb was used. I did something a little different in TP. When I needed to do things like that (displaying the available directions when the wristwatch is in COMPASS mode, for instance), I had a variable called "roomdesc_seen" in every room. It would flip back to false in the next loop, so I could always tell whether or not the user had just viewed the room description -- whether they entered the room or typed "look". Using the last_room (or something) variable I added, I could also track movement even in terse mode. Worked pretty well.

As for the color changing thing, the reason you couldn't do it in your class is because the room description in each room overrides the one in the class. These things add to the class, but if something is already defined in the class, the newer version replaces it instead.
Back to top
View user's profile Send private message Visit poster's website
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Wed Dec 15, 2004 1:06 pm    Post subject: Reply with quote

You can basically do what you are describing. Here is one example I did based on what you are describing:

Code:
class twistypassage
{
  is light
  long_desc
  {
    color DEF_FOREGROUND
    "These are twisty passages."
  }
  before
  {
    location DoLookAround
    {
      color YELLOW
      return RandomName
    }
  }
}


So there is my class. Now here is a room derived from that class:

Code:
twistypassage Passage
{
  long_desc "It is hard to tell this room from any other."
}


Then almost the same routine for randomizing given earlier:

Code:
routine RandomName
{
  local x
  x = random(3)
  select(x)
    case 1
    {
      self.name = "Twisty"
    }
    case 2
    {
      self.name = "Twistier"
    }
    case 3
    {
      self.name = "Twistiest"
    }
}


That seems to work for me in that I get a random name and it is colored yellow, including on the first time in the room.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Wed Dec 15, 2004 1:09 pm    Post subject: Reply with quote

Your room text returns to the normal color after the yellow title? I thought that your replacement of the long_desc{} would override your class def....??
Back to top
View user's profile Send private message Visit poster's website
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Wed Dec 15, 2004 1:16 pm    Post subject: Reply with quote

Merk wrote:
Your room text returns to the normal color after the yellow title? I thought that your replacement of the long_desc{} would override your class def....??


Yup. You are correct. My apologies. Let me look at this a bit more.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Wed Dec 15, 2004 1:24 pm    Post subject: Reply with quote

The only way I can think of that would let it work as a class is if the class had this:

Code:
long_desc {
    color DEF_FOREGROUND
    PrintRoomDesc(self)
}


You would then make a "PrintRoomDesc" routine with a handler for each room. Alternately, you could just add another property to the list... for instance "room_descr" -- put the real room description in the room_descr property for each object, and instead of calling PrintRoomDesc(self) just call self.room_descr instead. Should work too.
Back to top
View user's profile Send private message Visit poster's website
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Wed Dec 15, 2004 1:31 pm    Post subject: Reply with quote

In essence (and I'm not actually running this -- and it has been a few weeks since I coded anything, so please excuse if it turns out this is wrong):

Code:
property room_descr

class twistypassage
{
  is light
  long_desc
  {
    color DEF_FOREGROUND
    self.room_descr !Print real description
  }
  before
  {
    location DoLookAround
    {
      color YELLOW
      return RandomName
    }
  }
}

twistypassage SomeRoom ""
{
    room_descr {
        "Blah blah, a twisty room, like the others."
    }
}
Back to top
View user's profile Send private message Visit poster's website
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Wed Dec 15, 2004 1:34 pm    Post subject: Reply with quote

Merk wrote:
Alternately, you could just add another property to the list... for instance "room_descr" -- put the real room description in the room_descr property for each object, and instead of calling PrintRoomDesc(self) just call self.room_descr instead. Should work too.


Right - I find that works and is probably the better solution. I tried it out and that seems to work perfectly well.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
fleagor
Guest





PostPosted: Wed Dec 15, 2004 1:47 pm    Post subject: Reply with quote

Merk wrote:
Wouldn't that only make the title color yellow when you look? If you enter the room for the first time, that code shouldn't even run...


You're sort of right here. It gets run in color the first time, since I believe the parser just calls a DoLookAround, but when it displays things in compact mode, as per a subsequent visit to the room, it reverts to the default color. Good point though.

Back to the drawing board.
Back to top
Merk



Joined: 22 Nov 2004
Posts: 192
Location: Wichita, KS

PostPosted: Wed Dec 15, 2004 1:49 pm    Post subject: Reply with quote

You will probably need to change it back in the each_turn routine. If this isn't something you use for your rooms, then you can add each_turn {} to the room class definition and then it will be changed to default after the room description, whether it's printed or not.
Back to top
View user's profile Send private message Visit poster's website
fleagor
Guest





PostPosted: Wed Dec 15, 2004 5:52 pm    Post subject: Reply with quote

I'll definitely give the each_turn routine a shot. It'll probably be a couple days before I'll have time again to work on this though. I just wish I could figure out what was causing the behavior with the name property, with it outputting the newline and period. If I could get around that then I could do what you did with the room_descr property in the long_desc, only for the name. Very nice solution you came up with, by the way.
Back to top
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Sun Dec 19, 2004 8:54 am    Post subject: Reply with quote

fleagor wrote:
I just wish I could figure out what was causing the behavior with the name property, with it outputting the newline and period.

I am not sure about your progress on the overall issue here but this issue is probably based on the one I mentioned above in my earlier post. If you use a name property routine (with curly braces, { }) you are going to get that period and newline. (I cover this in the tutorial I wrote as well, so hopefully I am right on this!) If you make the name property just a "regular" property (what I am starting to call a "property set") and not a property routine, you should be okay - at least in terms of not getting the newline and period.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
fleagor
Guest





PostPosted: Mon Dec 20, 2004 4:05 pm    Post subject: Reply with quote

My progress has been approximately zero since last time; I kind of chalked it up to asking for the impossible. I had really hoped I could do something like Merk's solution for long_desc by creating a different property room_descr, but to no avail.

How would I go about making the name property a property set (I imagine this will open a whole different can of worms, but I'm still curious)? I didn't know there was a way to replace properties like you can with classes, or maybe I'm not quite following what you're saying. Also I noticed that "name" is one of the few compiler-defined properties, does that change things?
Back to top
fleagor
Guest





PostPosted: Mon Dec 20, 2004 4:28 pm    Post subject: Reply with quote

Cryptonomic,

I'm in the process of reading through your "Crafting a Hugo Game - Part 2", and it explains everything! Thanks for the detailed write-up, and I also wanted to say good job on making the whole thing easy to follow.
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended