ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Alpha on May 15, 2010, 02:42:42 PM
-
If you have 2 checkboxes in a menu is it possible to make it so that checking Box 1 will UNCHECK Box 2 ???
I'm making a short script with a Menu to do specials etc.. and I have it setup so that you simply check your primary or secondary special moves... Since you can't do both at one time I figured it would be nice to make it so that trying to check both checkboxes @ the same time was impossible..
For example..
If you have Box 1 (primary) checked & you check Box 2 (Secondary) it would then UNCHECK Box 1 and so on... I realize that you can set menu check to #false which will indeed clear the checkbox but it appears that #menures only remembers the last ACTUAL mouseclick or some such, and even if you reset it to #False it will return #True in #menures bc that was the last "phycial" input? Anyway running short on time ... Work etc.. but if Anyone is borred enough or already knows lemme know... If I failed to make it very clear I'll be back later heh..
Thx in Advance.
-
Take a look at TM's CLaw.
It does that when you check "loot ground items" it unchecks "automatic corpse looting.
-
step through this see if it helps.
menu check Checkbox1 0 20 90 30 #false Bottles
menu check Checkbox2 0 40 90 30 #false Kegs
menu show
main:
gosub box1
gosub box2
goto main
sub box1
Menu get Checkbox1
if #MENURES = -1 ;<----- -1 = checked 0 = unchecked
{
menu delete Checkbox2
menu check Checkbox2 0 40 90 30 #false Kegs ;<--unchecked
menu show
wait 2s
}
return
sub box2
Menu get Checkbox2
if #MENURES = -1 ;<----- -1 = checked 0 = unchecked
{
menu delete Checkbox1
menu check Checkbox1 0 20 90 30 #false Bottles ;<--unchecked
menu show
wait 2s
}
return
-
I hope this makes sense. This is a long way to do it, but I wanted to show a way to do what I think you were asking. This is fully working. Copy paste it into EUO and try it. If you're JUST trying to turn a checkbox off if another one is on NO MATTER WHAT, and don't want it selectable at ALL if one is clicked, I'll post code for that below the following code.
GOSUB menu
REPEAT
WAIT 1
GOSUB checkBoxes
UNTIL #CHARGHOST = YES
SUB checkBoxes
menu get checkbox1
IF #menures = #TRUE && %box1 = #TRUE
{
menu get checkbox2
IF #menures = #TRUE && %box2 = #FALSE
{
menu set checkbox1 #FALSE
set %box2 #TRUE
set %box1 #FALSE
}
}
menu get checkbox2
IF #menures = #TRUE && %box2 = #TRUE
{
menu get checkbox1
IF #menures = #TRUE && %box1 = #FALSE
{
menu set checkbox2 #FALSE
set %box2 #FALSE
set %box1 #TRUE
}
}
RETURN
SUB menu
menu Clear
menu Window Title EUOMenu1
menu Window Color BtnFace
menu Window Size 164 74
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style
menu Font Color WindowText
menu Font Align Left
menu Check checkbox1 32 20 97 17 #false Check Box 1
menu set checkbox1 #TRUE
SET %box1 #TRUE
SET %box2 #FALSE
menu Check checkbox2 32 40 97 17 #false Check Box 2
menu Show 421 270
return
Changing this sub to the below code will make it turn checkbox2 OFF whenever checkbox1 is #TRUE. Very simple. Great for things that will interfere with each other if they are checked. Kinda forces the user to select what you need them to. :)
SUB checkBoxes
menu get checkbox1
IF #menures = #TRUE
menu set checkbox2 #FALSE
RETURN
-
THX Script that was Exactly what I was looking for but I don't feel too bad now heh...
Heck when I asked in the Shout Box..
Alpha: Is there a command to uncheck a menu checkbox?
I got this Answer...
Cerveza: menu Check {name} {x} {y} {width} {height} {checked} {text} - CHECKED is either #true or #false
Which was all good because at that point I hadn't realized I could set #True / #False with the "Menu Check" commands...
But.... as I played with it I ended up with something amazing similar to what you posted.. Matter of fact if you replace that Mysterious
"Menu set checkbox1 #false" with a similar "Menu Check" command it don't work for $HIT lol... On a Side note.. I had already gone through the Docs reguarding Menu stuff http://wiki.easyuo.com/index.php/Menu_Set (http://wiki.easyuo.com/index.php/Menu_Set) and didn't think "menu Set Sets the text of a control " had anything to do with what I was looking for. Anyway thx again.. "Menu Set checkbox #false" etc was what I was missing...
GOSUB menu
REPEAT
WAIT 1
GOSUB checkBoxes
UNTIL #CHARGHOST = YES
SUB checkBoxes
menu get checkbox1
IF #menures = #TRUE && %box1 = #TRUE
{
menu get checkbox2
IF #menures = #TRUE && %box2 = #FALSE
{
;menu set checkbox1 #FALSE
menu Check checkbox1 32 20 97 17 #false Check Box 1 ;--Using this is what I was trying & didn't work at all..
set %box2 #TRUE
set %box1 #FALSE
}
}
menu get checkbox2
IF #menures = #TRUE && %box2 = #TRUE
{
menu get checkbox1
IF #menures = #TRUE && %box1 = #FALSE
{
;menu set checkbox2 #FALSE
menu Check checkbox2 32 40 97 17 #false Check Box 2 ;--Using this is what I was trying & didn't work at all..
set %box2 #FALSE
set %box1 #TRUE
}
}
RETURN
menu check Primary 5 5 85 20 #false Primary
SUB menu
menu Clear
menu Window Title EUOMenu1
menu Window Color BtnFace
menu Window Size 164 74
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style
menu Font Color WindowText
menu Font Align Left
menu Check checkbox1 32 20 97 17 #false Check Box 1
menu set checkbox1 #TRUE
SET %box1 #TRUE
SET %box2 #FALSE
menu Check checkbox2 32 40 97 17 #false Check Box 2
menu Show 421 270
return
Changing this sub to the below code will make it turn checkbox2
-
Remember that you define your menu in a subroutine seperate from everything else, and all the menu items can be controlled from in your script with menu set commands. But things like button colors need to be changed by deleting the old button and putting in a new button with a new color. Like if you wanted a grey button to turn red when clicked. I've got some really advanced button interaction subs I can post if you'd like. Take a day or two to rip them out of the scripts they are in tho. Just remind me in a day or two and I'll do it. Also, don't forget TM's list handling subs which no one really uses but are GREAT for some serious scripts... :) I love the list subs personally. They are hosted here and SO easy to use if you try them out if you find a use.
-
Yea I was aware of TM's list handling subs, but haven't looked at them yet. My Rule of Thumb is I try everything on my own & usually don't DL other's attempts until I start wondering how I could have made mine better. I've got a few things using some arrays though & I'm sure TM did a better job so I'll take a peek.