• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Search results

  1. H

    Is there a way to reffer a table itself inside the same table?

    Oh nice, it will work better, in what section I can learn more of this? Edit: I found it in the sections 13 and 16 of the reference manual.
  2. H

    Is there a way to reffer a table itself inside the same table?

    Oh ok, I got it. PD: I think I should put somthing like s.EditVal(self) does set self.val=5 to make more understandable what I said, but I think you understood it anyway.
  3. H

    Is there a way to reffer a table itself inside the same table?

    I searched about that and this is what I understand, the equivalent for what I want with colon syntax is: t={ val=3 ,EditVal=function(self) self.val=4 end } print(t.val) --Should print 3 t:EditVal() print(t.val) --Should print 4 Right? Edit, now I have another question, if...
  4. H

    Is there a way to reffer a table itself inside the same table?

    I searched and I didn't find anything, what I ask if I can do something like this, just to put an example: t={ val=3 ,EditVal=function() t.val=4 end } print(t.val) --Should print 3 t.EditVal() print(t.val) --Should print 4
  5. H

    Previous value in table

    If you wanna know this is the method I used, just I didn't think I will need it in Lua, but I think is too basic, can you tell me if is fine? local Next={[0]=0} local Prev={[0]=0} function InsertToList(node,replace) Next[node]=replace Prev[node]=Prev[replace] Next[Prev[node]]=node...
  6. H

    How works metamethods?

    Well.
  7. H

    Previous value in table

    If the solution is use a linked list then I know what to do, I knew how to do one.
  8. H

    Previous value in table

    I tried something like this, its ok? [email protected] t table [email protected] i integer if is nil this will return the last value [email protected] any,any function prev(t,i) if t then if not i then return #t,t[#t] end local k1,v1 for k,v in pairs(t) do if v==i then return...
  9. H

    Previous value in table

    As well as exists the function "next" to get the next value in a table, is there an equivalent to the previous value if I set the index?
  10. H

    How works metamethods?

    So I can just redefine the existing metamethods, right?
  11. H

    How works metamethods?

    Well I understand a little more, but my question is, how can I declare a metamethod and how can I call it?
  12. H

    How works metamethods?

    I know I can investigate it, but I think is better is someone explains me.
  13. H

    Is there a way to detect when a variable is edited?

    I ask this because I wanna know if I have a variable lets call it x, and somebody do x=<value>, but the value is invalid for some reason I wanna establish so then automatically x is set to nil.
  14. H

    Optional Library

    Question, how much I can use the function pcall?, because I wanna display error messages but the print function only exists if I have a boolean called "TEST_MODE" equal true, because is better when it compiles the function from the beggining do nothing instead of checking the value TEST_MODE...
  15. H

    Optional Library

    Thanks for the explanation
  16. H

    Optional Library

    Oh sorry, I think we have a diferent meaning of library, because I thought it just was putting: do --The variables --The functions end I think this is in my case because I program in Warcraft 3 and to share us functions and objects we do that. But just in case, can you tell me how to...
  17. H

    Optional Library

    Yes, and if there is not, a way to "ignore" the functions it has.
  18. H

    Optional Library

    I'm not sure if you have an idea of what library means, but in my case when I say library is a code with functions and data that I can use to help me in my programming and that I can share with others, just I wanna know if there is a way to detect if there is that library in my code to erase or...
  19. H

    Text macro

    What is that?
  20. H

    Question about comments

    I see.
Top