Making Hugo Programs

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

hiddenHeart

Making Hugo Programs

Post by hiddenHeart »

kindly anyone tell me how to make a simple program using Hugo programming language?..

i already download hugo compiler

and i wanted to make simple program with input,output, and simple looping statements.

yet i don't know how to use it. or where do i type my codes or what so ever...

in short:
i just wanted to run simple program using hugo language.

can anyone help me?

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

Post by Roody_Yogurt »

I don't know exactly what you are asking here. I don't know if you are trying to start a text adventure with Hugo or if you want to write a simple non-text-program. Both can be (and have been) done. I'll go through both.

First off, though, the code goes into a text file that we give a .hug extension to separate it from the rest of the files on the computer. That is the file that will be fed to the compiler.

If you are wondering where Hugo's IDE is, the way that Inform 7 and TADS 3 have their own IDES, Hugo does not have an IDE, unfortunately. We still use regular text editors here. We have a list of text editors with syntax files (files that allow you to color code your code) here:
http://hugo.gerynarsabode.org/index.php ... ed_Editors

(As far as free Windows editors go, I'd recommend TextPad, just because it handles comments and strings just a little bit better than the other free ones.)

Ok, let's go into the programming:
  1. Making your own program-
    Your own program can be as simple as a file containing:

    Code: Select all

    routine main
    {
    	print "HELLO WORLD"
    	pause
    	quit
    }
    Larger examples of such code are http://ifarchive.org/if-archive/program ... retest.hug and http://ifarchive.org/if-archive/games/s ... source.zip .
  2. Making interactive fiction-
    To make a real text adventure, you'll need what we call the "shell" file, which you can pick up here: http://roody.gerynarsabode.org/bareshell.hug

    You'll also need the standard library, on Hugo's official site or the IF archive.

    If you compile that bareshell just as it is and run the resulting file, you'd find yourself in an undescribed room with pretty much nothing to do (well, you can >EXAMINE ME since the player character object has a default description).

    Since it's nice to have an untouched shell around, I like to make a copy of it then rename the copy to the game I'm going to write and start with that one.

    Anyhow, at that point, you're ready to start making your game world.

    Here is another overview for beginners getting into Hugo:
    http://hugo.gerynarsabode.org/index.php ... ng_Started

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

Re: Making Hugo Programs

Post by Tdarcos »

hiddenHeart wrote:kindly anyone tell me how to make a simple program using Hugo programming language?
Hugo isn't really a "general purpose programming language" like Basic, PHP or C. Hugo is a specialized language designed for implementing Interactive fiction. Yes, in theory you could use it for designing regular apps, but it would be like, say, trying to use a spreadsheet program to create a general purpose application, like a payroll program or accounts payable. The system isn't really a good fit for that purpose. (But keeping the values generated by transactions in a payroll or A/P app is an excellent use of a spreadsheet.)

What Hugo is really good for is the implementation of an application where the user types in a command and the program issues a response based on the command. (There are features for mouse-based input and some other things.) This tends to be a near-perfect match for text adventures and certain other game type applications. If you were doing some inquiry program then Hugo might be a good fit, but here and now either an HTML page or an interactive website does a much better job for that sort of thing.

But don't let me scare you away if you think Hugo would be a useful system for developing a program for something you want to do. But for general purpose programming - other than the specialized game-type systems that other interactive fiction authoring systems are used for - something like Basic or Pascal or C might be a better choice.

FreeBasic includes an IDE for developing Basic programs, and the Lazarus editor provides an excellent IDE for compiling programs in Free Pascal, either language is good for general-purpose software development.

But if you really are looking for a way to implement a game, then I suspect Hugo really might be the right choice. The run-time libraries and such do a lot of the "heavy lifting" and implement a lot of the stuff you'd have to do if you were writing a game - especially interactive fiction - using a general purpose language like Basic, C, Java, Pascal, Perl or PHP.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

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

Re: Making Hugo Programs

Post by Ice Cream Jonsey »

Tdarcos wrote:
hiddenHeart wrote:kindly anyone tell me how to make a simple program using Hugo programming language?
Hugo isn't really a "general purpose programming language" like Basic, PHP or C.
Hugo is turing complete and the source code is open and available. So I must once again correct one of your posts.
the dark and gritty...Ice Cream Jonsey!

hiddenheart

Post by hiddenheart »

thanks everyone for the help... i'll try them soon...

i guess text editor is all i need here :smile:

anyway, i'm not going to create payroll systems or what.. i just wanted to use hugo for creating simple program that uses input/output statement, and looping statements..i guess every programming language uses such statements before they can create games and what....

i hope to make it :smile:

hiddenheart

Post by hiddenheart »

Roody_Yogurt

i still can't make it.. how can i be able to make file containing the codes you've given me with a .HUG extension?...

or how can i run my file if its not in a .HUG / .hex / .hdx extension?....

im very confused :sad: :sad: :sad: :sad:

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

Post by Roody_Yogurt »

Oops, sorry, hiddenheart, I saw your first reply there but hadn't realized you followed it up with another one right away.

It seems there's a bit of a language barrier here so I'm not sure what is being asked. To create a new file, in the text editor, go to /File/New. When you 'Save As', you should be able to save it as the file type you'd like.

.Hug files must be compiled to turn into .hex files, which you run with the interpreter program (hewin.exe, he.exe). If you're looking to create a standalone program, you could download the Hugor interpreter and rename the hugor.exe file to match your .hex file, so if your game file is called hiddenheart.hex, rename hugor to hiddenheart.exe and then opening THAT will automatically open the game.

Now, I assume that if you have found this board, you have already taken a look at the other parser-based (what you call input) programs that are available. We are glad to have you, but in case you aren't aware of the other choices, let me share some links:

Inform 7 is the most popular IF system. It is coded using a weird English syntax. The homepage is at http://inform7.com/ .

Quest and ADRIFT are two other languages that are fighting for people's attention.

Quest will let you design your game in a web browser: http://www.textadventures.co.uk/quest/

ADRIFT: http://www.adrift.co/cgi/adrift.cgi

Don't be sad, hiddenheart!

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

Post by Roody_Yogurt »

Also, if the important thing is the choices and not the typing, maybe you want to take a look at a choose-your-own-adventure (CYOA) system like Twine:

Twine home page - http://gimcrackd.com/etc/src/
A "How to Use Twine" page - http://www.auntiepixelante.com/twine/

hiddenheart

Declaring Variables

Post by hiddenheart »

Thanks... i Can now create output statement using hugo.. :smile:

but im wondering on how do we declare variables in hugo?...

for example in java we use:
String a="hidden";
int b=10;

then how would the code be for hugo?...

i also wonder how to get a user input in hugo...?
in other codes, we use "input.getText()"
how about in hugo?..

i already read the HUGO BOOK in pdf file and tried the codes there on how to declare variable..
just type:
x=0;

but an error occurs.. even in declaring strings..

is there any other way?..
or am i missing something?..

:sad: [/b]

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

Post by Roody_Yogurt »

Variables have to be declared as global or local. Here is an example of declaring both:

Code: Select all

global variable_A = "red" ! start pointing to "red" 

routine SetThemVariables
{
   local variable_B = 5 ! equals 5
   local variable_C, variable_D ! some local variables without starting values
   variable_A = "blue" ! now points to "blue"
   variable_B = 10 ! now equals 10

   print variable_A ! should print "blue"
   print number variable_B ! should print "10"
}
Now, there are a couple different ways to get input. If you want people to type in full commands, you can use input/GetInput. GetInput is the same as input except it'll print a prompt, so:

Code: Select all

GetInput("type your answer>")
Will print "type your answer>" before expecting input from the player.

All understood words will be put into the word array; the first understood word will be put in word[1], the second understood word will be put in word[2], and so on. The first not-understood word will be put in the parse$ global variable, but all other not-understood words will be lost.

The good news is that any text your code checks for is automatically in the dictionary table and will be understood.

The other way to get input is to just use a while loop to do one-key inputs, where the player types just a letter (not full words). The simplest way to do that is:

Code: Select all


routine GetKey
{
    local key
    pause ! pauses the game, waits for keypress
             ! (the keypress gets sent to word[0]
    key = word[0]
    select key
        case 'a','A' : "The player typed A."
        case 'b','B' : "The player typed B."
        case else : "And so on."
}
Hope that helps! Cheer up, HH!

hiddenheart

thanks!

Post by hiddenheart »

THANKS A LOT Roody_Yogurt for the help..

i can now report Basics of Hugo Programming Language to class...


Super Thanks!
:smile: :smile: :smile: :smile:

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

Post by Roody_Yogurt »

You're welcome, hiddenheart! Sounds like one lucky class!

Erebor
Posts: 27
Joined: Sat Dec 22, 2012 1:53 pm

Hugo programming difficulties--(first attempt).

Post by Erebor »

I'm not entirely sure where the appropriate place is to post this question/problem, but I'm choosing to do so here, rather than create a new topic.

Anyone is welcome to comment, but I'm specifically addressing this to Robb. I'm a Mac User, and I recently downloaded the Hugo Compiler for OS X, along with all the necessaries to get started programming for Hugo. The Hugo Book seems very straightforward and understandable. I'm well into the first two sections, and I wanted to get started playing around with the compiler. Bear in mind, that I have a basic familiarity with C++, and general computer science concepts, which I learned in college.

The problem that I'm having seems to be that Terminal crashes immediately when I run the compiler. I've tried both double-clicking it, and running it from within Terminal, the usual way. In both cases, I end up with a "process completed" message, and a screen with which I can do nothing. This is Terminal's way of saying that the program has ended... the program which I just opened. All the menus seem to be in the right place, just inactive.

I'm not sure why this is happening. I'm certain that the download from the Hugo site was perfectly suitable for Unix users in general, but there seems to be an assumption on the part of those who make these packages available that all Mac users are command line experts, which is not the case. The command line didn't even exist for us, prior to OSX. While that has been awhile, I've been a Mac user for several years (an embarrassingly long period of time), and I'm feeling like I'm having to learn about my computer all over again... being so unfamiliar with Terminal. One of my CS professors said that the GUI makes us all dependent and stupid. I suppose that's right. I like having a command line interface on my system... I'm excited about the potential for what it can accomplish. I'm just not that familiar with it. Nearly all my experience has been interacting with the system at the macro level, with the GUI. However, I don't believe I'm actually doing anything wrong here. My first impulse was to allocate more RAM for Terminal, to keep it from crashing-- which in this version of OS X, I'm no longer allowed to do.

Can someone give me some idea what's going on here? Once I get over this first hiccup, I think I can get on with my artistic endeavours... but I need something to experiment with, first.

Can we at least establish if the OSX download from the HUGO site definitely works on a system running OSX? I suspect that someone may have just given me some Unix files and hoped for the best.

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

Post by Roody_Yogurt »

Unfortunately, yeah, the packages on the Hugo site don't work with the modern OSX and Unix OSs. ICJ and some others put together alternate packages but they have not yet been incorporated into the Hugo site. I don't have the link handy, but I'm sure ICJ will give the link as soon as he sees this thread.

Anyhow, will be happy to help out with any Hugo coding questions as soon as you get that far!

User avatar
Jizaboz
Posts: 4811
Joined: Tue Jan 31, 2012 2:00 pm
Location: USA
Contact:

Post by Jizaboz »

Yeah, I wish there were a proper and pretty Hugo compiler for OSX. I end up uploading my work to a linux box to compile it, then pull it down.. which is a pain. I end up just firing up my crappy Toshiba to work on Hugo stuff.

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

Re: Hugo programming difficulties--(first attempt).

Post by Ice Cream Jonsey »

Erebor wrote:The problem that I'm having seems to be that Terminal crashes immediately when I run the compiler. I've tried both double-clicking it, and running it from within Terminal, the usual way. In both cases, I end up with a "process completed" message, and a screen with which I can do nothing. This is Terminal's way of saying that the program has ended... the program which I just opened. All the menus seem to be in the right place, just inactive.

I'm not sure why this is happening.
Yeah, the Mac versions that are on the General Coffee site do not work. This ... this is tough. We were able to get a fix for Unix, but the Mac compiler is in no-man's land. :(

We did get it working for Unix. The repository is here:

http://hg.0branch.com/hugo-unix

Let me know if you can or cannot get that to work.

I realize that this is the most bullshit way to get introduced to a programming language. I get it. I had no access to a Mac, so I couldn't fix the Mac compiler (keeping in mind that, hey, I am primarily just a game-maker here, haha).

I hope that you can find a way to take this journey with us. I'm still making games in Hugo. I suspect I will be for a very long time. I do have a Mac laptop thanks to work, but that came with a price: I'm so busy at work that I haven't had time to research the specific Mac Hugo problem.

(And to confirm, the Unix compiler available through generalcoffee.com does not work - you need to grab the hc in that repo linked above.)
the dark and gritty...Ice Cream Jonsey!

Erebor
Posts: 27
Joined: Sat Dec 22, 2012 1:53 pm

Relieved

Post by Erebor »

Well thanks, man. And to all for replying. Especially Robb for posting that link. I'm just glad to know that I'm not insane, or such a hopeless backward newb that I'll never get anywhere.

I'll experiment with the new program, and let you know how it goes.

I actually have a couple of projects in mind that I think will look great in HUGO, that I want to do as practice.

bruce
Posts: 2544
Joined: Tue Jun 04, 2002 10:43 pm

Post by bruce »

I just did an hg clone of the bitbucket source, and ran a make on OS X 10.10.

It seemed to run fine. A few warnings, but nothing too concerning. I don't have any Hugo source to test it on, but when I invoke the compiler and debugger they give me what look like appropriate startup banners:

Code: Select all

adam@i7-wired:~/Documents/src/hugo/hugo-unix$ ./hc
HUGO COMPILER v3.1.04 by Kent Tessman (c) 1995-2006
The General Coffee Company Film Productions
Unix port by Bill Lash

SYNTAX:   ./hc [options] sourcefile [objectfile[.HEX]]
OPTIONS&#58;  -<switches>  $<limit>  #<compiler>  @<directory>

SWITCHES&#58;
  -a  Abort on first error                -d  build .HDX Debuggable executable
  -f  Full object summaries               -h  generate .HLB precompiled Header
  -i  print debugging Information         -l  List compilation output to disk
  -o  display Object tree                 
  -s  display compilation Statistics      -t  Text to .LST for spellchecking
  -u  show memory Usage for objectfile    -v  Verbose compilation
  -w  Write objectfile despite errors     -x  override switches in source code

LIMIT SETTINGS&#58;  $<setting>=<new> &#40;or $list to view&#41;
DIRECTORIES&#58;     @<directory>=<actual> &#40;or @list to view&#41;

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

Post by Ice Cream Jonsey »

You grabbed the repo from here? http://hg.0branch.com/hugo-unix

I am under the impression that it wouldn't work on a Mac even though they are essentially running BSD now because it's just different enough to require specific Mac builds.

Oh wait, you ran a make. Maybe if I read your post all the way through they would make greater sense. Maybe I should do that for everyone.

Can I send you credentials to download my WIP? If it compiles that and works then shit, I guess the fixes I put in for the Unix version would be good enough for the Mac version.
the dark and gritty...Ice Cream Jonsey!

bruce
Posts: 2544
Joined: Tue Jun 04, 2002 10:43 pm

Post by bruce »

Ice Cream Jonsey wrote:You grabbed the repo from here? http://hg.0branch.com/hugo-unix
Yep.
Can I send you credentials to download my WIP? If it compiles that and works then shit, I guess the fixes I put in for the Unix version would be good enough for the Mac version.
Sure.

Post Reply