Thread Tools Display Modes
Prev Previous Post   Next Post Next
04/14/14, 04:24 PM   #1
Etupa
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 8
Help with toggle value/function

Hi here, need your help I've messed up with else if or etc make 0 1 as a var... don't get it at all ;_;

I'm trying to make a toggle function with one keybinds, bindings.xml part is ok for me but have no more idea for lua... u_u

Basicaly, I want 0 became 1 or 1 became 0 ... ^^;

Lua Code:
  1. local function helm()  
  2.         local control = ZO_OptionsWindow.controlTable[3][8]
  3.         SetSetting(control.system, control.settingId, 0)   
  4.     end
  5. --or
  6.  
  7.     local function nohelm()
  8.         local control = ZO_OptionsWindow.controlTable[3][8]
  9.         SetSetting(control.system, control.settingId, 1)   
  10.     end

Thanks for your help :c




Edit :
where I am now ... ; ;


Lua Code:
  1. function toghelm()
  2. local control = ZO_OptionsWindow.controlTable[3][8]
  3. SetSetting(control.system, control.settingId, (var))
  4.     var = x
  5.         if x == 0 then return nohelm()
  6.         elseif x == 1 then return helm()
  7.     end
  8.  
  9. end
  10.            
  11.     local function helm()  
  12.         local control = ZO_OptionsWindow.controlTable[3][8]
  13.         SetSetting(control.system, control.settingId, 0)   
  14.     end
  15.     local function nohelm()
  16.         local control = ZO_OptionsWindow.controlTable[3][8]
  17.         SetSetting(control.system, control.settingId, 1)   
  18.     end

tried also something like

Lua Code:
  1. function toghelm()
  2. local control = ZO_OptionsWindow.controlTable[3][8]
  3. SetSetting(control.system, control.settingId, (var))
  4.    var = helmvar
  5.       if helmvar == 1 then var = 0
  6.       elseif helmvar == 0 then var = 1
  7.    end
  8. end

Well, those always return 0 (helm is on) ... but can't catch the way to make 0 to 1 et 1 to 0 at function execution ^^;


one more try...

Lua Code:
  1. function toghelm()
  2.     local control = ZO_OptionsWindow.controlTable[3][8]
  3.         local helmstate = GetSetting(control.system, control.settingId)
  4.         if helmstate == 1 then return helm()
  5.         elseif helmstate == 0 then return nohelm()  
  6.     end
  7. end
  8.  
  9.            
  10. local function helm()  
  11.     local control = ZO_OptionsWindow.controlTable[3][8]
  12.     SetSetting(control.system, control.settingId, 0)   
  13. end
  14.  
  15. local function nohelm()
  16.     local control = ZO_OptionsWindow.controlTable[3][8]
  17.     SetSetting(control.system, control.settingId, 1)   
  18. end

really don't get it

Last edited by Etupa : 04/15/14 at 03:58 AM.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Help with toggle value/function


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off