.Commands
and generals
.Creating
a picture-gump
.Interactive
gumps
Let's start with a little list of the available commands.
Don't wonder about their outlook. Gumps are a client-feature and have
(nearly) nothing in common with eScript.
All parameters are colored red.
page 0You should know that page 0 contains all background-commands. Means that everything you specify between page 0 and page 1 will be visible everytime the gump is open.
This line belongs to page 0
This line, too
And this one
page 1
This now belongs to page 1
var gflayout := {You see, the last parameter is 0 and therefore means that the text which is to be found in the data-array on position 0 will be shown at position x=100, y=100 in color 0 (black). Yes, the first position in an array is 0 [for gumps] - not 1 as usual in eScript. [as I said - they have nearly nothing in common]
"page 0",
"text 100 100 0 0" // last parameter = text-id
};
var gfdata := {
"This is the first textline"
};
<center> = means "center" - the text in between <center> and </center> is always in the middle of your text-areaOne example for a html-formatted data-array-entry:
<br> = means "break" - the text goes on in the next line (this one does not need a "</br>" at the end)
<b> = means "bold" - the text in between <b> and </b> is displayed in bold letters
<i> = means "italic" - the text in between <i> and </i> is displayed in italic letters
<u> = means "underlined" - the text in between <u> and </u> is underlined
var gfdata := {One thing you can actually not do [or I just don't know how] : Change the color of your text. It is always black. [If htmlgump does not put out what I mention here, you may be using a client that is too old. The only chance is to use a more up-to-date one]
"<center>Hello guys!</center>;<br>
<br>
This one is a html-gump.<br>
Features?<br>
<b>o</b>Html-tag supported
<b>o</b>Real Scrollbar
<b>o</b>Nice background ;)"
};
var gflayout := {That would create a transparent resizepic with a full visible border. [I'm not totally sure about its outlook, but you'll get the idea of the effect]
"page 0",
"resizepic 100 100 5054 100 200",
"checkertrans 110 110 80 180"
};
var gflayout := {This is correct.
"page 0",
"text 100 100 0 0",
"text 100 115 0 1"
};
var gflayout := {This is incorrect.
"page 0",
"text 100 100 0 1",
"text 100 115 0 0"
};
var choice := SendDialogGump( who, gflayout, gfdata );
var pressed_buttons_id := choice[0];
Now this was all very theoretical. Now we'll experiment with
these things. I guess most of you will start here and take a look at
the descriptions later.
I mentioned some of these things before, but repetition did never harm
anyone.
So, a gump is constructed in two arrays. [You should already know arrays and how to
handle respectively create or modify them. If not
please read Rac's EScript-guide
first!]
Normally you just write value after value in an array but to make it
more clearly you should put them one below another
- just like this:
var gflayout := {Thus you'll get a better overview and can add comments more easily.
"page 0",
"text 100 100 0 0",
};
use uo;Well - read the comments carefully? [If not, do it now, please] Then you should have understood the main "body" of a gump. You always need "page 0" - the rest is optional. [Though a gump without content seems to be a bit useless, don't you think?]
use os;
include "include/attributes";
program gumptest( who )
var gflayout := {
"noclose", // close by right-click forbidden
"nodispose", // you did not want to hit esc, did you?
"nomove", // you musn't move the window around
"page 0", // we initialize the first page which is the background
"resizepic 100 100 3600 300 300", // this is the dark background
"text 145 120 32 0", // the headline "my first picture-gump"
"page 1", // now we initialize the second page ...
"text 120 160 50 1", // ... and create some text-lines...
"text 120 175 50 2",
"text 120 190 50 3",
"text 120 205 50 4",
"text 120 220 50 5",
"text 120 250 50 6",
"text 120 265 50 7",
"button 240 360 5540 5541 0 2 0", // the button to switch to page 2
"page 2", // we initialize the third page (page 2)
"text 140 230 50 8", // the last text-line ...
"button 188 230 249 248 1 0 0" // ... in which we place a button
};
var gfdata := { "<[ My first Picture-gump ]>", // these are only textlines which are used
"Your skin-color : "+who.color, // in the layout-description above, namely
"Your gender : "+who.gender, // in order from top to bottom.
"Your strength : "+getattribute(who,ATTRIBUTEID_STRENGTH),
"Your dexterity : "+getattribute(who,ATTRIBUTEID_DEXTERITY),
"Your intelligence : "+getattribute(who,ATTRIBUTEID_INTELLIGENCE),
"Click the arrow to proceed",
"to the next page",
"Press [okay] to exit" // the text around (and behind) the okay-button
};
SendDialogGump( who, gflayout, gfdata );
endprogram
Ok, we should first make clear what interactive gumps
are: I see an interactive gump as a gump which
"communicates" with a player and returns his choice so the script does
what he wants it to do. Take the hair-dye-gump as an example of such a
gump.
You already know how to write a (rather simple)
gump - but that's only a piece of what you can do with gumps. You can
create multiple-choice menus, election-gumps, shopping-lists,
theater-bills and so on ...
So - how do we get to know what the player wants? First we
have to make the send-part of our program a variable so we can refer to
it, after the player made his choice. Like this:
var his_choice := SendDialogGump( who, gflayout, gfdata );Easy? Yes!
var his_choice := SendDialogGump( who, gflayout, gfdata );Now you would have the whole key-array in a new array, called keys - but this is no use. We have to split the keys and get the right one so we can make the script act in the way we want it to.
var keys := his_choice.keys;
keys[0] = 0 // always emptyIf you press the 1500-valued radio-button and the "normal" button the output would look like this:
keys[1] = 500 // 500 < 1000; therefore you'll find the radio-value here
keys[2] = 1000 // 1000 > 500; thus the button's key has got this place
keys[0] = 0 // always emptyI bet you all see the difference.
keys[1] = 1000 // 1000 < 1500; therefore you'll find the button-value here
keys[2] = 1500 // 1500 > 1000; thus the radio's key has got this place
var choice;After this loop you would have the highest value in the variable choice. Then you can work with it, create a case-statement or many ifs - it's up to you.
foreach key in keys
choice := key;
endforeach
use uo;This would be a working gump. Depending on what the player chooses one of the given messages will appear. Why? That is what you should already know. I only wrote this example so you can see how a working gump with radios looks like. Sometimes some expressions are not comprehensible at once. So the code should explain what maybe some of you didn't understand exactly.
use os;
program gumptest( who )
var gflayout := {
"page 0",
"nodispose",
"resizepic 0 0 5170 200 300",
"radio 100 100 5540 5541 0 100", // All radio-values are important and thus
"radio 100 120 5540 5541 0 200", // greater than any button-value [in this example: 1]
"radio 100 140 5540 5541 0 300",
"button 100 180 249 248 1 0 1"
};
var gfdata := { };
var choice := SendDialogGump( who, gflayout, gfdata );
var his_choice;
foreach key in ( choice.keys )
his_choice := key;
endforeach
var output;
case ( his_choice )
100: output := "The player chose the button the value of which is 100";
200: output := "The player chose the button the value of which is 200";
300: output := "The player chose the button the value of which is 300";
default: output := "The player must have canceled the gump without doing anything";
// default means if the value is neither 1 nor any of the radio-values
// [so the player canceled the gump without doing anything]. In this example it doesn't matter
// whether you press the okay-button or not, the values are counted anyways. This is because
// it is not important for this example. If you're writing a gump and want it to work correctly
// you should embed a test if the okay-button was pressed
// [like this: if ( choice[0] == 1 ) <- then the player has pressed the okay-button.
// Why? You should know]
endcase
SendSysMessage( who, output );
endprogram
var choice;Now we add each key to the new variable, called choice. If it was enough to look at one radio/button -value [see example-code above] you now have to ask for a sum of all values respectively all possible values.
foreach key in keys
choice := choice + key;
endforeach
use uo;Whenever you press a checkbox + button in this gump you should receive a message what you've done. [It does not work? Tell me!]
use os;
program gumptest( who )
var gflayout := {
"page 0",
"noclose",
"nodispose",
"resizepic 0 0 5170 200 300",
"checkbox 100 100 5540 5541 1 100", // I set the "status"-parameter to 1
// In this way the player has to make a decision
"checkbox 100 120 5540 5541 0 200",
"checkbox 100 140 5540 5541 0 400",
"button 100 180 249 248 1 0 1"
};
var gfdata := { };
var choice := SendDialogGump( who, gflayout, gfdata );
var his_choice;
foreach key in ( choice.keys )
his_choice := his_choice + key;
endforeach
var output;
// Now you either have to create a formula or you must calculate
// all possible values and then ask for them. I'll use the second method now
// CB = Checkbox
case ( his_choice )
101: output := "CB 1 + Button";
201: output := "CB 2 + Button";
301: output := "CB 1 + CB 2 + Button";
401: output := "CB 3 + Button";
501: output := "CB 1 + CB 3 + Button";
601: output := "CB 2 + CB 3 + Button";
701: output := "CB 1 + CB 2 + CB 3 + Button";
default: "output: This should not have happened";
endcase
SendSysMessage( who, output );
endprogram
use uo;Well - why does the gump appear as it does? Simple explanation: The checkertrans-command defines an area - using the given parameters - and makes everything which lies in that area and which has been defined before it, translucent. Of course you may create those translucent areas as big or small as you like. Is that everything? Yes, it is!
use os;
program translucent_gump_test( who )
var gflayout := { "page 0",
"resizepic 50 80 2620 400 40", // This resizepic is completely translucent
"text 65 86 2101 0", // This text is translucent, too
"checkertrans 56 86 386 28",
"text 250 86 2101 1" // This text is 100% visible
};
var gfdata := { "Durchsichtiger Text",
"Undurchsichtiger Text"
};
SendDialogGump( who, gflayout, gfdata );
endprogram
use uo;Short info for the script above: As to the textentry, all things that are connected to each other are marked in the same colors.
use os;
use util;
use cfgfile;
program textentry_gump( who )
var gflayout := { "page 0",
"resizepic 50 80 2620 400 110",
"checkertrans 56 86 386 288",
"text 160 100 2101 0",
"TextEntry 150 130 200 20 40 0 1" // An explanation of the parameters can be found in this chapter
};
var gfdata := { "Textentry-Gump-Example",
"YOUR TEXT HERE" // The default text of the textentry
};
var result := SendDialogGump( who, gflayout, gfdata );
sendsysmessage( who, "You typed: "+result[0][4, len(result[0])] );
endprogram
var mystring := "I ate a hotdog";Now mystring contains: "I ate a dog".
mystring[9, 3] := "";