Unflappable Drayk adc. Posted May 7, 2012 Share Posted May 7, 2012 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? Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk nikki. Posted May 7, 2012 Share Posted May 7, 2012 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. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted May 7, 2012 Share Posted May 7, 2012 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. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast The Mystic Posted May 7, 2012 Share Posted May 7, 2012 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. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk adc. Posted May 8, 2012 Author Share Posted May 8, 2012 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... Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Enraged Slith Posted May 8, 2012 Share Posted May 8, 2012 There's no easy way to describe what you want to use them for until you've actually delved into scripting and run into a situation where you need to use them. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted May 8, 2012 Share Posted May 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted May 8, 2012 Share Posted May 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk adc. Posted May 8, 2012 Author Share Posted May 8, 2012 Trial and Error. I get that rarely. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast The Mystic Posted May 8, 2012 Share Posted May 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk nikki. Posted May 8, 2012 Share Posted May 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Ephesos Posted May 8, 2012 Share Posted May 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk adc. Posted May 10, 2012 Author Share Posted May 10, 2012 Sdf's... hmmm... have been hearing about that since I started tinkering with Geneforge scripts... I used to disregard those things... and yet, now I need to check it out. What is a/an sdf? Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Enraged Slith Posted May 10, 2012 Share Posted May 10, 2012 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. Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Dintiradan Posted May 10, 2012 Share Posted May 10, 2012 Stuff Done Flag. It's a way of storing and retrieving numbers. Take a look at page 75 of the Manual, or this excellent article by Kelandon. Quote Link to comment Share on other sites More sharing options...
Understated Ur-Drakon Celtic Minstrel Posted May 10, 2012 Share Posted May 10, 2012 SDFs are basically game-global variables – variables you can access from any script, as opposed to the local variables in the "variables" section which can only be accessed in the script they are declared in. Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Ishad Nha Posted May 11, 2012 Share Posted May 11, 2012 Also, SDFs enable numbers to be stored permamently, unlike the variables found in town/outdoor zone scripts. Quote Link to comment Share on other sites More sharing options...
Understated Ur-Drakon Celtic Minstrel Posted May 11, 2012 Share Posted May 11, 2012 Where "permanently" means "until the party leaves the scenario". Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast The Mystic Posted May 14, 2012 Share Posted May 14, 2012 Originally Posted By: Alor Goodbye And, it's entirely possible not to use variables at all; I know I've done without them in the past. Yeah, I tend to avoid variables too, except when I'm creating a loop in the code. Quote Link to comment Share on other sites More sharing options...
Unflappable Drayk adc. Posted May 15, 2012 Author Share Posted May 15, 2012 So... the flag things are what now? Are they items or special items? Quote Link to comment Share on other sites More sharing options...
Understated Ur-Drakon Celtic Minstrel Posted May 15, 2012 Share Posted May 15, 2012 Stuff done flags are not items. They're global variables. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk nikki. Posted May 15, 2012 Share Posted May 15, 2012 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. Quote Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted May 15, 2012 Share Posted May 15, 2012 And you kind of need to read the documentation and look at some example scripts, or you're never going to get this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.