If there's one thing that drives me nuts, it's that I cannot, for the life of me, figure out how to put global defines into my code. What I'm thinking about doing is throwing all my defines into a separate logic all its own, kind of like a decoder code of sorts. I notice that very few fanmade games out there utilize defines anywhere in the code, so how does everybody use them? I agree with Joel that defines can make an AGI game much easier to code.. I just can't seem to make it a reality! Arggg...|
And what is the point of the message declarations I see at the bottom of the logics? Everybody declares them, but nobody ever seems to use them in the same way as the tutorials put it.
You guys are the reason why AGI lives on...
using defines is recomended.. especially when your game gets bigger.|
basically, you define your variables in a file called defines.txt and include it at the top of each logic file that you have. This is what is happening now, there are plans to update the syntax but that's a long way off.
I don't think agi studio lets you access it directly, so you might have to use explorer to open it.
All text messages are stored in the message section at the bottom. The thing is, the compiler does this automatically at compile time.. so when you're compiling your own code, you won't see the messages at the bottom.. they're added later to the logic resource. If you're disassembling code, then the decompiler will handily display all the messages at the bottom.
The reason for this is because mesages can refer to other messages inside themselves.. so the decompiler just plays it save and plonks all messages at the bottom instead of just the ones that are recognised.
Just to make sure it's clear -- when you open up a fan-made game in AGI Studio, you're not seeing what the author sees. You're seeing what AGI Studio has reconstructed from the compiled code. Unless the fan-made game comes with a bunch of files called things like logic0.txt, logic4.txt, etc., then you don't have the author's original source code so when you open the game you'll see a bunch of stuff without defines (because define names aren't actually saved into the compiled game). Although I use defines extensively in my code, if you were to open up Jen's Quest you'd see the same define-less mess.|
It is possible to edit defines.txt for your own game in AGI Studio. You just have to use the text editor instead of the logic editor.
There is a purpose to putting messages at the bottom of the logic. It allows you to abbreviate print statements if you use the same message in several different situations. For example, you could say:
That would cause the message "You can't do that" to be displayed whenever the player typed "look at the door", "eat the apple", or "kill the fish", and you wouldn't have to retype the message. Also, as Nick said, you can include messages inside of other messages, which I think reduces the size of compiled logics. I use this technique in my game. For example:
If the player typed, "talk to kristen", then the game would print:
Jen: "Hey, Kristen..."
If I use the dialog prefixes a lot, then instead of having six extra bytes of data for each time Jen talks and 10 extra bytes of data for each time Kristen talks, I only have 3 extra bytes of data any time either of them talks plus a one-time cost of around 20 bytes of data for both dialog prefixes to be defined.
That's a great idea to reuse "Jen" and "Kristen".. you could actually go one step further and reuse them across the game by using global strings.|
Any strings that are defined in logic.0.. you can access them via the %g (global) msg command. Because they're in logic.0.. they're always available.
Okay, I finally figured out what I was trying to do. I put in the defines into my code and put the #include "defines.txt" header.. and it didn't work.. because I couldn't figure out what the error was telling me. The defines.txt file must be in the src directory... I guess I'm just used to the error messages not making sense (in C++ and COBOL [don't even say it]) that I didn't take the message literally!!|
Thanks be to Peter Kelly and Nailhead for making the error messages actually UNDERSTANDABLE!! Whatta concept!