My programming experience is trying to learn ATARI BASIC out of books when I was 10, a college course called Liberal Arts Mathematics that covered logic, and trying to read first the TADS manual, then the Inform manual, and now the Hugo manual, off a computer screen. I don't have a job where I can print out the bible for free.
So, I can see how Hugo has a little bit more of an intuitive and simple grammar structure than, say, TADS or Inform, but also how they're very similar. I am stuck at properties and routines (I think I hit the wall at around page 83 of the Hugo manual). I understand creating an object and giving it attributes and properties. But I don't understand this object.nouns business. Say, I have an object called FatAss; with the nouns property defined. What does FatAss.nouns do?
I am also not clear on how to call a routine. I thought I could do something like this:
routine main
{ print "Hello sailor!"
}
routine Bob
{ print "Hello Bob!"
}
Bob
and get two lines of text. I don't understand why "Hello sailor!" gets printed right off the bat; what is calling the main routine? Why doesn't Bob print also? And how do I call "Bob", if not by saying "Bob" (the file compiles if I leave out that last line -"Bob"- but doesn't if I put it in. Nonetheless, it was my attempt to call the Bob routine)?
???
stuck
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
I'll try to answer this although I'm really not good. I can barely write a game myself.
I believe a main routine is always called. That's why in shell.hug, you can see the main routine saying all of this:
counter = counter + 1
PrintStatusLine
run location.each_turn
runevents
RunScripts
if parent(speaking)~=location
speaking = 0
But if you have nothing calling your Bob routine, it won't execute. If you ran Bob from within Main (if you can do that), I'm sure it'd show up.
Also, on the horizon is a printed Hugo manual for purchase from iflibrary.org. It'll be priced reasonably closed to the cost of printing, so it should be a good deal.
In the meantime, it's good to read the current Hugo manual and sent Kent your thoughts on its readability and coverage of issues that try you.
I believe a main routine is always called. That's why in shell.hug, you can see the main routine saying all of this:
counter = counter + 1
PrintStatusLine
run location.each_turn
runevents
RunScripts
if parent(speaking)~=location
speaking = 0
But if you have nothing calling your Bob routine, it won't execute. If you ran Bob from within Main (if you can do that), I'm sure it'd show up.
Also, on the horizon is a printed Hugo manual for purchase from iflibrary.org. It'll be priced reasonably closed to the cost of printing, so it should be a good deal.
In the meantime, it's good to read the current Hugo manual and sent Kent your thoughts on its readability and coverage of issues that try you.
- Ice Cream Jonsey
- Posts: 30193
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Hey, let me welcome you to the BBS, looper. Hope this base can be of some help for you.
Roody said exactly what I was going to say -- the main routine is always called, so that's what executes that line. I think you want to have something like this, though, to get both lines to print:
There are other places where you can call Bob. For instance, you might want to call that routine the first time you enter a room. The way the program flow would work would be something like this:
o the "main" routine is called
o the player is placed in Room1 (for instance) by a line that goes something like MovePlayer(Room1)
o You could then set something up where, if the player had never been in that room before, Bob() would be called.
... Does that make any sense at all? Let me know if there are any questions we didn't answer to your satisfaction, looper.
Robb
Roody said exactly what I was going to say -- the main routine is always called, so that's what executes that line. I think you want to have something like this, though, to get both lines to print:
Code: Select all
routine main
{
print "Hello sailor!"
Bob()
}
routine Bob()
{
print "Hello Bob!"
}
o the "main" routine is called
o the player is placed in Room1 (for instance) by a line that goes something like MovePlayer(Room1)
o You could then set something up where, if the player had never been in that room before, Bob() would be called.
... Does that make any sense at all? Let me know if there are any questions we didn't answer to your satisfaction, looper.
Robb
the dark and gritty...Ice Cream Jonsey!
-
- Posts: 94
- Joined: Mon Feb 24, 2003 12:32 am
- Location: CA
ThanksIce Cream Jonsey wrote:Hey, let me welcome you to the BBS, looper. Hope this base can be of some help for you.

Makes sense. I think one thing that confuses me a little is how the routine Bob is defined at the end of the program but called in the middle. Doesn't make intuitive sense to me. But I guess I'll just have to take a look at the chapter that covers that...I'll be back when something else confuses me! Thanks again!Ice Cream Jonsey wrote:Code: Select all
routine main { print "Hello sailor!" Bob() } routine Bob() { print "Hello Bob!" }
... Does that make any sense at all? Let me know if there are any questions we didn't answer to your satisfaction, looper.
Robb
- Ice Cream Jonsey
- Posts: 30193
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Right, I am with you -- I didn't get that at first either. What the compiler does, though, is make a note of your call to "Bob" and wait until it gets through processing your code before stating that it doesn't know what it is. So when it sees Bob() defined below, it essentially says, "OK, cool" and is alright with the fact that you called it before you wrote it (in terms of how the text file containing your source code is written).looper wrote:Makes sense. I think one thing that confuses me a little is how the routine Bob is defined at the end of the program but called in the middle. Doesn't make intuitive sense to me. But I guess I'll just have to take a look at the chapter that covers that...I'll be back when something else confuses me! Thanks again!
I think there are a few languages out there where you need to define your routines before you can call them, but offhand I can't remember which ones. (I could be totally wrong as well, but I could swear that such a question came up in some intro to programming class that I slouched about in over the years.)
the dark and gritty...Ice Cream Jonsey!
That's pretty much it
One of the key things is to not think of a Hugo source file as a contiguous script--it doesn't really matter, in the general case, what order things are included in. (There are times when it matters, but we're not concerned about that here.)
And yeah, languages like C/C++ require you to "prototype" a function before calling it, meaning you have to give some sort of additional description of what the function is called, etc. before you can use it. In Hugo, the compiler just looks at the function when and where it's defined, and relates that directly to each place where that function is called. (Hopefully what this means is less work for the programmer.)
And yeah, languages like C/C++ require you to "prototype" a function before calling it, meaning you have to give some sort of additional description of what the function is called, etc. before you can use it. In Hugo, the compiler just looks at the function when and where it's defined, and relates that directly to each place where that function is called. (Hopefully what this means is less work for the programmer.)