Official ScriptUO EasyUO Scripts > Scripting Tutorials

Tutorial idea

(1/1)

M4yH3m:
I would love it if someone could make a tutorial on making a menu with checkboxes, and then how to write the code so that when a checkbox is checked, the code uses whatever skill is checked. I am a complete noob when it comes to coding, and I want to learn SO bad. But I have no idea what I am doing. I take scripts, and dissect them, and kind of know some things, but I really would like to see some tuts geared towards people like me, who have NO basic skills whatsoever. Maybe even a live stream on the Discord channel? I learn better by hands on training, I can read the same thing over and over, and it still makes no sense to me lol!!Thanks everyone.

Gaderian:
For any of the basic menu elements, the process is the same.
1) Create a form (menu).
    setup alignment, font, and size for text
    optionally create a panel (it helps with menu control later)
    create the checkboxes in the panel
    make the form visible
2) In your logic that processes your script, you will 'get' the values of the menu element.
    It could be a checkbox, radio button, edit, combo box or listbox - it is the same for any of these, so no reason to say otherwise.
    Now you act on the value you retreived.

Here is a simple menu with a few check boxes:

--- Code: easyuo ---gosub formM4yH3m while #menubutton <> formM4yH3m { menu get chk1 set %checkbox1 #menures menu get chk2 set %checkbox2 #menures  gosub ProcessMenuOptions    } halt sub ProcessMenuOptions if %checkbox1 = #false && %checkbox2 = #true  {  menu setprop status alignment 1  menu setprop chk2 alignment 1  menu setprop status text Right  } if %checkbox1 = #true && %checkbox2 = #false  {  menu setprop status alignment 0  menu setprop chk1 alignment 0  menu setprop status text Left  } if %checkbox1 = %checkbox2  {  menu setprop status alignment 2  menu setprop chk1 alignment 2  menu setprop chk2 alignment 2  menu setprop status text Centered  }return sub FormM4yH3m menu form formM4yH3m 100 100 500 250 Example checkboxes menu setprop formM4yH3m visible #true menu setdef fontname  MS Sans Serif menu setdef alignment 2 ; 0 = left, 1 = right, 2 = center menu text status 50 10 text$text ; syntax for check box parameters: ;menu Check {name} {x} {y} {width} {height} {checked} {text} menu panel Panel1 10 50 400 150 menu check chk1 10 10 300 15 #false Check box 1 (left) menu check chk2 10 30 300 15 #true Check box 2 (right)return 
Gaderian
I have no real answer on why it dances across the screen, but this was just to show some of the options. Apparently I did something wrong in there on my choices. It gives you something to play with.

Gaderian:
Now there are 2 systems of making menu code. Personally I go with the more recent one, because most everything (other than my botched alignment example) works really nicely.

There is an old version of easyuo (1.42) and a menu designer. That can be nice for creating a flexible layout. If you want to convert from the code that creates to the modern one, you have to change about 5 statements or so from the standard code.

It is nice for it's flexibility, but some of the old menu commands no longer function. If you look at older written menu code, it was limited to a single menu. So if you wanted to draw a new menu... you had to clear (erase) the current one... draw the new menu... then when complete clear the new on and redraw the original one.

The new system allows you to have multiple forms (menu's) at the same time. So you can hide it (menu setprop {formname} visible #true/#false) and make the original one come back by a similar command... just opposite visible settings.

I created the old vs. new commands in one of my tutorials - which is supposed to help show how to rewrite some of the older commands into the new system equivalents.

Gaderian

Navigation

[0] Message Index

Go to full version