Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Delgar
Beginner


Joined: 22 Dec 2008
Posts: 21

PostPosted: Sun Dec 13, 2009 2:56 pm   

[3.12] Lua .enabled field not working correctly on floating buttons or events
 
The code is below the description.

I created a floating button and an event and attempted to use Lua to enable/disable them.
Using the get<type> Lua functions to create variables to the different objects and then assigning true/false to the .enabled field to attempt to enable/disable the object.
Setting enabled to true on the floating button works correctly, but the button only sometimes goes away when after assigning false to enabled.
Assigning true/false to the enabled field of the event never works.


I created the standalone test script and objects to demonstrate the issue (I did not test the other object types).
1. Import the XML into a clean session (only the Lua script will be enabled). TB1 is a normal button, TB2 is a floating button, TT1 is a normal trigger, and TE1 is an event.
2. Type "tld enable".
3. TB1, TB2, and TT1 will enable, but TE1 stays disabled.
4. Manually enable TE1.
5. Type "tld disable".
6. TB1 and TT1 will disable, TB2 will disable but the button stays a majority of the time, and TE1 stays enabled.
7. Comment out the lines for assigning to .enabled and uncomment the lines that use zs["T+"] and zs["T-"].
8. Run the script again and things work correctly.

Thanks,
-- Delgar

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="tld" language="Lua">
    <value>local tb1 = zs.getbutton("TB1")
local tb2 = zs.getbutton("TB2")
local te1 = zs.getevent("TE1")
local tt1 = zs.gettrigger("TT1")

if (zs.param(1) == "enable") then
  tb1.enabled = true   -- works
  tb2.enabled = true   -- works
  te1.enabled = true   -- doesn't work
  tt1.enabled = true   -- works
  -- zs["T+"]("TB1")   -- works
  -- zs["T+"]("TB2")   -- works
  -- zs["T+"]("TE1")   -- works
  -- zs["T+"]("TT1")   -- works
else
  tb1.enabled = false  -- works
  tb2.enabled = false  -- disables, but button doesn't always go away
  te1.enabled = false  -- doesn't work
  tt1.enabled = false  -- works
  -- zs["T-"]("TB1")   -- works
  -- zs["T-"]("TB2")   -- works
  -- zs["T-"]("TE1")   -- works
  -- zs["T-"]("TT1")   -- works
end
</value>
  </alias>
  <trigger name="TT1" priority="54500" enabled="false">
    <pattern>^THIS IS A TEST TRIGGER$</pattern>
  </trigger>
  <button name="TB1" priority="54460" enabled="false">
    <caption>T1</caption>
  </button>
  <button name="TB2" toolbar="0" priority="54470" enabled="false">
    <caption>T2</caption>
  </button>
  <event event="onRoomWalk" priority="54480" name="TE1" enabled="false"/>
</cmud>
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Dec 14, 2009 5:52 pm   
 
I'll add the issue with Events not disabling via Lua to the bug list.

The issue with the floating button not going away is that CMUD doesn't know to refresh the screen when you disable the floating button in Lua. If you do anything that causes the screen to refresh, like resize it or something, then you should see the button go away.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net