More interesting GUMPS -




A tutorial by Tracker-Morgan of Shattered Alliance
http://gray-cat.com/alliance/
email me: morganmichaels@hotmail.com


Gumps and dialogs are the same thing, just for reference, and I use either word to mean the same thing. They are windows, text, or pictures that pop up onto someone's screen when you do:

dialog d_my_dialog

That is how you make a dialog pop up on someone's screen, by the way. I've been asked how to do that enough times to make sure to include it. Like most things in sphere, "dialog" is a function that you can run on players. Whoever you "point" to is the one who recieves the dialog. To make a dialog pop up for someone when something is double-clicked, you would do:

on=@dclick
src.dialog d_my_dialog
return 1

SRC is a pointer, that points to the person that double clicked. You could also do anything similar to that:

on=@step
src.dialog d_my_dialog

on=@targon_char
src.targ.dialog d_my_dialog

on=@timer
link.dialog d_my_dialog
//or even
cont.dialog d_my_dialog

An interesting note is that any string variable can be used in the dialog calling like this:

src.dialog d_<tag.race>

This would pop up d_human if then were human, d_orc if they were an orc, or d_squirrel if they were a were-squirrel. I recommend using this instead of a on of IF statements that determines which race they are, and then pops up the right dialog. Of course, having a different gump for each race is inefficient when you could simply use one that was dynamic enough to change according to what you are.

To make a dialog appear in-game, you can type .dialog d_my_dialog. To make a dialog appear on someone else, you can type .xdialog d_my_dialog.

...for the rest of the basics, read Taran's tutorial at http://ithycaworld.com/ Read the whole damned site, actually, and practice some before doing any of this.

What did I mean by dynamic? Well, you can use variables in place of ANY number in a dialog.

text 14 147 0 <eval 0<tag.health>>

...is one example of the use of a tag. The last number is the "index" number, which points to which row of the TEXT portion of the dialog to look at. I had a TEXT portion like this:

[dialog d_health_bar TEXT]
( )( )( )( )( )( )(Healthy)
(X)( )( )( )( )( )(Bruised)
(X)(X)( )( )( )( )(Injured)
(X)(X)(X)( )( )( )(Wounded)
(X)(X)(X)(X)( )( )(Mauled)
(X)(X)(X)(X)(X)( )(Crippled)
(X)(X)(X)(X)(X)(X)(Incapacitated)

If tag.health was 2, for instance, it replaced:

text 14 147 0 <eval 0<tag.health>> with text 14 147 0 2

...which displayed to the user as:

(X)(X)( )( )( )( )(Injured)

The same could be done for something like race and class.


text 20 200 0 <eval 0<tag.race>>
text 20 220 0 <eval 0<tag.class>+5>
//I add +5 to it, so that it skips past the race section.
//If I wanted to add another section, such as alignment, I would have to make it skip past the class section.

[dialog d_character TEXT]
Race: Human
Race: Orc
Race: Troll
Race: Elf
Race: Dwarf
Race: Monkey
Class: Fighter
Class: Farmer
Class: Magician

The TEXT portion of the gump is not limited to simple things, believe it or not. You can just as easily put...

[dialog d_character TEXT]
Race: Human

..as you can put...

[dialog d_character TEXT]
Race: <tag.racename>
AC: <eval (<findlayer(13).armor>/10)+(<findlayer(12).armor>/10)+(<findlayer(11).armor>/10)>
<findid.i_pet_timer.link.name>


Let's say that I want a dialog that shows a picture of what a person has in each hand, and tells me some info about each one.
Now, how to get the information that I need?


[dialog d_wearing]
0,0
page 0
resizepic 0 0 5054 340 480
resizepic 8 8 3000 322 462

text 180 20 <eval <findlayer(1).color>> 1 //make the color the color of the item. Cute, eh?
text 180 40 <eval <findlayer(1).color>> 2 //Remember to always use eval because dialogs functions normally
text 180 60 <eval <findlayer(1).color>> 3 //think in decimal, not hexadecimal.
text 180 80 <eval <findlayer(1).color>> 4

tilepic 40 62 <eval <findlayer(1).id>> //findlayer(1) points to what a person has in layer 1...the right hand.

text 180 120 <eval <findlayer(2).color>> 5
text 180 140 <eval <findlayer(2).color>> 6
text 180 160 <eval <findlayer(2).color>> 7
text 180 180 <eval <findlayer(2).color>> 8

tilepic 40 162 <eval <findlayer(2).id>> //a pic of the item

[dialog d_wearing TEXT]
<var.blanknothingness>
Name: <findlayer(1).name>
Color: <findlayer(1).color>
Timer: <findlayer(1).timer>
UID: <findlayer(1).uid>
Name: <findlayer(2).name>
Color: <findlayer(2).color>
Timer: <findlayer(2).timer>
UID: <findlayer(2).uid>


That dialog is pretty innefficient, though. I already have 8 text statements, and I would need to add about 9 more lines of code for each other layer that I wanted to add info for. I need to make it more dynamic. I think I'll simply replace the "1" in "findlayer(1)" with "<tag.which_layer>", and add buttons to scroll through the different layers on a person.

First, I'll add the code for the button section.


[dialog d_wearing BUTTON]
onbutton=1150
tag.which_layer=<eval 0<tag.which_layer>+1> //add one
dialog d_wearing //re-call the dialog

onbutton=1151
tag.which_layer=<eval 0<tag.which_layer>+(-1)> //subtract one
dialog d_wearing //re-call the dialog


Now I'll modify the text section to use <eval 0<tag.which_layer>> instead of findlayer(1 or 2). Notice that I'm using less code then before, but now I can show the info on any of the layers!

[dialog d_wearing TEXT]
<var.blanknothingness>
Name: <findlayer(<eval 0<tag.which_layer>>).name>
Color: <findlayer(<eval 0<tag.which_layer>>).color>
Timer: <findlayer(<eval 0<tag.which_layer>>).timer>
UID: <findlayer(<eval 0<tag.which_layer>>).uid>
Layer: <eval 0<tag.which_layer>>

Then I'll edit the dialog section to match. We end up with a hideously ugly dialog that is actually somewhat useful.

[dialog d_wearing]
0,0
page 0
resizepic 0 0 5054 340 480
resizepic 8 8 3000 322 462

text 180 20 <eval <findlayer(<eval 0<tag.which_layer>>).color>> 1
text 180 40 <eval <findlayer(<eval 0<tag.which_layer>>).color>> 2
text 180 60 <eval <findlayer(<eval 0<tag.which_layer>>).color>> 3
text 180 80 <eval <findlayer(<eval 0<tag.which_layer>>).color>> 4
text 180 120 0 5 //Layer: 1

tilepic 40 62 <eval <findlayer(<eval 0<tag.which_layer>>).id>>

button 170 200 4502 4502 1 0 1150 //next
button 20 200 4506 4506 1 0 1151 //previous


Other things that are very useful:

<rescount *i_whatever*>
//A script that would count all of someone's reags would use this like this:
[dialog d_reag_count TEXT]
<rescount i_reag_garlic>
<rescount i_reag_ginseng>

<restest 1 *i_whatever*>
//A dialog that would tell a person if they had any common items would use this like this:
text 180 180 0 <restest 10 i_bandage>
text 180 200 0 <restest 1 i_potion_healing>
text 180 220 0 <restest 1 i_spellbook>
text 180 240 0 <restest 20 i_arrow>
//restest returns 1 if they have that many of that item, 0 if they don't.

[dialog d_item_check TEXT]
NO
YES


<findlayer(*x*)>
//Can be used in an amazing number of ways.
//To show if they have anything equipped there, for example:
text 180 180 0 <findlayer(1)>
[dialog d_item_check TEXT]
NO
YES
//Would say yes if something is equipped, no if nothing is equipped.

<findlayer(*x*).(variablename)>
//Can be used aboslutely any way you can imagine. IE:
[dialog d_item_check TEXT]
Morex: <findlayer(1).morex>, Morey: <findlayer(1).morey>, Morez <findlayer(1).morez>


<findid.*i_whatever*.*item variable*>
//Great for checking variables on memory objects.
[dialog d_item_check TEXT]
Your long sword's morez: <findid.i_sword_long.morez>
The name of the object your memory object is linked to: <findid.i_memory_object.link.name>




What other creative uses for Gumps can I think of?

-People often ask how to set the light level for just one person...well...it's impossible. You could, however, "blind" a person by opening a screen-wide gump on them every second or so from a timer.
-You can cause text, tilepics, resizepiics, and such to "move" by changing their x and y variables. This can be used to do things such as "hiding" images underneath other images, moving unwanted text off the screen, etc...

text <tag.textx> <tag.texty> 0 1

[dialog d_my_dialog BUTTON]
onbutton=1150
tag.textx=<eval 0<tag.textx>+1> //add one
tag.texty=<eval 0<tag.texty>+1>
dialog d_my_dialog

-Using tags, a person could design basiic gumps in-game by doing something to the effect of:
[dialog d_very_dynamic_gump]
0,0
page 0
resizepic <tag.rpicx1> <tag.rpicy1> <tag.rpicid1> <tag.rpicw1> <tag.rpich1>
resizepic <tag.rpicx2> <tag.rpicy2> <tag.rpicid2> <tag.rpicw2> <tag.rpich2>
resizepic <tag.rpicx3> <tag.rpicy3> <tag.rpicid3> <tag.rpicw3> <tag.rpich3>

text <tag.textx1> <tag.texty1> <tag.textc1> <tag.textindex1>
text <tag.textx2> <tag.texty2> <tag.textc2> <tag.textindex2>
text <tag.textx3> <tag.texty3> <tag.textc3> <tag.textindex3>

tilepic <tag.tpicx1> <tag.tpicy1> <tag.tpicid1>
tilepic <tag.tpicx2> <tag.tpicy2> <tag.tpicid2>
tilepic <tag.tpicx3> <tag.tpicy3> <tag.tpicid3>

[dialog d_very_dynamic_gump TEXT]
<tag.gumptext1>
<tag.gumptext2>
<tag.gumptext3>


Of course, I would use eval and such so it would actually work. You could even create a gump that let you create a gump...

What can you NOT do with gumps?

-You can't close a gump that someone haas open through script, only when a player right-clicks or presses a button.
-You cannot re-color a tilepic, resizeppic, etc...without editing your .mul files and adding a re-colored version of it in. You can make a new paperdoll, for instance, but you cannot change the colors of the tilepics for the items.


© 1