Move a control from lua
Hi,
from http://www.esoui.com/forums/showthread.php?t=1541 i ve a lua code like the Clear / SetAnchor, Code:
AddOnUI:ClearAnchors(); As exemple, see 1.2.{3.1,3.2}. Where 2:SetAnchor( _, 1, _,_,_); I clear from 3.2, then 3.1, then 2, then 1 and reset in the first order. But that works once and after my UI get bad offset (typically, my label go to the cursor), and UI's position isnt reset. |
Quote:
just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) |
I strongly advise against passing the variable _ to a function, unless you have declared it locally (assuming that's what you meant in the example).
It is commonly used as a "junk" variable so could contain any random value. |
I used _ to exprim "any variable you want put here".
2:SetAnchor( _, 1, _,_,_) have to be read like 2:SetAnchor( pos1, 1, pos2,offx,offy) Quote:
|
This depends on how your controls are defined, if you can post a few lines of code maybe we can figure out why controls does not want to move.
|
The parts about the concerned code :
Lua Code:
The XML: Code:
<Controls> |
Quote:
Lua Code:
Also in my opinion both backdrop and texture needs two anchors: Lua Code:
|
Quote:
Quote:
|
just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer)
just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer) ... If there is NO specific event that 's the only thing you can do (well that and a timer)! If for any reason you don't want to do that because the Player should be able to move the frames then you have to think about a better solution with booleans n' stuff ... |
Quote:
Quote:
|
Oh guess it was language difficulties - he 's trying to MOVE it then afterwards after anchoring it to another position?
Ok OnUpdate is a bad idea then ... |
It works better since i ve removed a lign :
Lua Code:
This was causing me so many troubles... With your clue about offset, i saw on zgoo that my defaults were updated by the move. From a Lua Code:
*** I m using Lua Code:
|
Judging from your most recent reply, I'm guessing that you have something along the lines of this:
lua Code:
Can you see the problem? Tables are not copied upon assignment, they are referenced. So "settings = defaults" and then "settings.x = someNewNumber" in fact changes the value of your "defaults.x". |
Not really the trace i imagine about my code, but we can resume like it.
On the one hand, you have to remind than I m new with Lua. In the other hand, can you see i solved my problem ? What I did when I understand it. My last post was just to inform than I solved my problem (which is a table's newb problem, I concede it...). |
The point of my post was to inform you of something important that happens in lua, because like you said, you are new to it. It is a common mistake and worth mentioning, even if you did already solve your problem. Just trying to teach :)
Without learning this information about how tables are assigned, then you're likely to make the same mistake again in the future (if you DID make that mistake). |
All times are GMT -6. The time now is 12:23 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI