So my question is, what is the best way to get the script to watch for a ui button push and change a variable?
Here is my last attempt, which failed with no errors in the console or message being printed--probably because cvar floor_select is not being changed and is still NIL or 0.
Code: Select all
level waittill prespawn
setcvar "floor_select" 0
level.floor_select = 0
$e_object time 3
thread button_tester
=================================
button_tester:
$e_object_trigger waittill trigger
pushmenu test_widget
while (1)
{
level.floor_select = getcvar(floor_select)
if (level.floor_select == 1)
{
iprintln "Floor " (level.floor_select) " selected!"
$e_object moveto $way_1
$e_object waitmove
level.floor_select = 0
}
if (level.floor_select == 2)
{
iprintln "Floor " (level.floor_select) " selected!"
$e_object moveto $way_2
$e_object waitmove
level.floor_select = 0
}
if (level.floor_select == 3)
{
iprintln "Floor " (level.floor_select) " selected!"
$e_object moveto $way_3
$e_object waitmove
level.floor_select = 0
}
if (level.floor_select == 4)
{
iprintln "Floor " (level.floor_select) " selected!"
$e_object moveto $way_4
$e_object waitmove
level.floor_select = 0
}
wait .1
}
end
Code: Select all
menu "test_widget" 640 480 FROM_RIGHT .3
align right center
bgcolor 0.0 0.0 0.0 0.0 // rgb background color of menu; alpha
borderstyle "RAISED"
resource
Label
{
name "Default"
rect 499 104 84 166
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.50 0.50 1.00 0.75
borderstyle "RAISED"
}
resource
Label
{
title "FLOOR"
name "Default"
rect 506 112 70 29
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.50 0.50 1.00 0.50
borderstyle "NONE"
//font facfont-20
//font courier20
font verdana-14
//font handle-22
}
resource
Button
{
title "4"
name "Default"
rect 506 142 70 29
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.89 0.79 0.05 0.75
clicksound "sound/items/mptypekey.wav"
borderstyle "3D_BORDER"
stuffcommand "set floor_select 4"
}
resource
Button
{
title "3"
name "Default"
rect 506 172 70 29
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.89 0.79 0.05 0.75
clicksound "sound/items/mptypekey.wav"
borderstyle "3D_BORDER"
stuffcommand "set floor_select 3"
}
resource
Button
{
title "2"
name "Default"
rect 506 202 70 29
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.89 0.79 0.05 0.75
clicksound "sound/items/mptypekey.wav"
borderstyle "3D_BORDER"
stuffcommand "set floor_select 2"
}
resource
Button
{
title "1"
name "Default"
rect 506 232 70 29
fgcolor 0.00 0.00 0.00 1.00
bgcolor 0.89 0.79 0.05 0.75
clicksound "sound/items/mptypekey.wav"
borderstyle "3D_BORDER"
stuffcommand "set floor_select 1"
}
end.


