Jump to content

Mysterious letters...


adc.

Recommended Posts

This script was taken from "A Small Rebellion" scenario...

// TOWN SCRIPT

// Town 0: Willow

 

// This is the special encounter script for this town.

// The states INIT_STATE, EXIT_STATE, and START_STATE have

// meanings that are described in the documenation. States you write

// yourself should be numbered from 10-100.

 

 

begintownscript;

 

variables;

 

int i,j,k,r1,choice;<----------- these things!!!!

short donnaud_ask = 1;

 

body;

 

beginstate INIT_STATE;

//Names must appear first.

set_name(18,"Forbes");

set_name(19,"Chelsea");

set_name(20,"Aboro");

set_name(21,"Welde");

 

 

Seriously, what do those things mean? What does it do? What can it be it's effect? Can somebody please tell?

Link to comment
Share on other sites

Those are variables.

 

Basically, a variable (in this instance) is a number referred to by a name, just like in algebra. They're used when you have a number you want to change, or for numbers you don't yet know the value of.

 

As for an example of how you might use them, say I wanted to reduce the HP of a party member by 10%. I couldn't possible know what the PC's full health is initially, so I would use a call to find out, and then store the result in a variable. Using that variable, I could then apply the correct math (multiplying by 0.9) to reduce the party member's health.

 

Link to comment
Share on other sites

Nikki covered most of the high points, but it's worth noting that in Avernumscript all of the variables are declared (created) following the 'variables' statement (third line in your example town script) and nowhere else, and that on each line where variables are declared the first word is the kind of variables being declared. In your example, you can see that the two lines begin with 'int' and 'short', which mean the same thing, namely that the variables will be able to hold integers. The other kind of variable in Avernumscript is 'string' which holds a chunk of text, but most variables are integers.

Link to comment
Share on other sites

What Nikki and Niemand said.

 

Also, those variables were created when the scenario was originally ported from BoE to BoA, and are used by the script generated. For whatever reason, though, sometimes the porting process ends up declaring variables that aren't used; the town script you quoted, t0Willow.txt, doesn't use i, j, and k, only r1 and choice.

Link to comment
Share on other sites

Alright, so... at an example, I just want to create a simple town WITHOUT giving quests, no dialogue pictures, no special stuff, just those simple talking dialogues. Where do I start? What variables will I use?

 

Quote:
Those are variables.

 

Basically, a variable (in this instance) is a number referred to by a name, just like in algebra. They're used when you have a number you want to change, or for numbers you don't yet know the value of.

 

As for an example of how you might use them, say I wanted to reduce the HP of a party member by 10%. I couldn't possible know what the PC's full health is initially, so I would use a call to find out, and then store the result in a variable. Using that variable, I could then apply the correct math (multiplying by 0.9) to reduce the party member's health.

 

Then, I can use any letters then instead of the familiar i,j,k,r1.

 

Another question:

How do I use them? Are they required for quests and anything relevant?

-----------

I think they're not on the docs. Or maybe I skipped them... Can't tell which, just inform me if it is actually at the docs...

Link to comment
Share on other sites

Originally Posted By: Rehctawthgin
I think they're not on the docs. Or maybe I skipped them... Can't tell which, just inform me if it is actually at the docs...

This stuff is covered in various of the sections of Chapter 2.8 in the Docs.

For simple tasks like simple dialogue, giving and ending quests, message boxes that just display some task without asking the player to make a choice (so they offer only one option, like 'OK') can all be done without needing variables. Probably the first thing for which you'll want to use variables is a message box with more than one choice, where what the game does needs to depend on what the player chooses. However, as Enraged Slith points out, once you want to do more complex things and look at how other peoples' script do them you'll mostly know when you need variables. Until then there's no need to worry about them.

If you're really keen on learning how to use variables, I would recommend studying the door script ('door.txt'). You already know how doors behave form playing the game, I'm sure, so be reading that script you can find out how the code works to create that behavior.
Link to comment
Share on other sites

If you've figured out SDFs, then you use them for anything that you don't want to bother setting an SDF for, because it's meaningless outside the state that you're messing with right now. An SDF is for something that you might check later; a variable is for something that you'll never check again.

 

If you haven't figured out SDFs, figure out SDFs first.

Link to comment
Share on other sites

Originally Posted By: Rehctawthgin
Alright, so... at an example, I just want to create a simple town WITHOUT giving quests, no dialogue pictures, no special stuff, just those simple talking dialogues. Where do I start? What variables will I use?
If you're just making simple dialogue, with nothing special about it and no code, then you probably won't need variables at all.

Originally Posted By: Rehctawthgin
Then, I can use any letters then instead of the familiar i,j,k,r1.
You can use pretty much whatever you want as a variable name, as long as you follow the rules outlined in the docs.
Link to comment
Share on other sites

And, it's entirely possible not to use variables at all; I know I've done without them in the past.

 

The best thing you can do, as said, is take a look at some existing scripts, and try writing a little practice code. You'll pick it up much easier that way.

Link to comment
Share on other sites

Also, just as a general point of interest, I would recommend that you use better variable names in your own scripting. And by "better", I mean more descriptive. It makes a world of difference when you go back to an old script and know exactly what the variable "total_brooms" means, instead of staring at the screen for half an hour to figure out what exactly the function of "k" was.

Link to comment
Share on other sites

SDFs are basically a tool used for organizing events in your scenario. For instance, you can prevent a special encounter/state from occurring until a specific SDF is set to a certain value. Here's a simple example:

 

Code:
beginstate 10;	if(get_flag(10,0) == 2){ //dictates that this specific event will only occur when the SDF is set to 2		message_dialog("The magical glyphs no longer eminate their dreadful aura; you are free to pass, unhindered.","");		set_flag(10,0,3); //sets your SDF to a different value to prevent this special encounter from activating again		}	if(get_flag(10,0) < 2){ //dictates that this specific event will only occur when the SDF is below 2		message_dialog("As you try to pass over the glyphs, a feeling of dread takes hold and chills your heart.  Overwhelmed, you stagger away from the terrible pressence.","");		block_entry(1); //prevents the party from moving forward		}break;

 

Due to SDFs, you can have this state do multiple things depending on its current value. In this example, I used SDFs to prevent the player from moving past a certain location until they've completed an event elsewhere in the scenario.

Link to comment
Share on other sites

Basically the way to think of Stuff Done Flags is as indicators which tell you what things have and haven't been done in a scenario; they flag up stuff that's been done.

 

As an example, say I wanted to remember whether or not the party had asked Bob the Mayor about "dragons"; if the party had then the Stuff Done Flag would be set to a number other than 0 (the default status for all flags - think of this as "off" if it helps), and I would be able to check for this in other scripts.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...