1. Hi there Team,

    I'm working to port the Level and Skill System from Oxide 1 to Oxide 2, but I stuck on the Group management.
    How its possible to remove a Table Entry (key) and all its values?
    Ex.:
    Code:
    LESData.json =
    "GroupData": {
        "Testers": {
          "Leader": [
             "PlayerX"
          ],
          "Members": [
             "PlayerX"
          ]
        }
    tableremoveentry(LESData, Testers)

    Then, all the group Testers would be remove with its info.
     
  2. Just set it to nil and it will magically disappear :D
    Code:
    LESData.json.GroupData.Testers = nil
     
  3. Oooww, will test that!

    I was so focused in doing it using a function that I created this:

    Code:
    function PLUGIN:tableRemoveKey(table, key)
        local element = table[key]
        table[key] = nil
        return element
    end
    
    Then used: self:tableRemoveKey(GroupData, GroupName)
     
  4. Sometimes just a simple solution will do ;)
     
  5. Tried it and it gave me an error in the console, checked the file LESData.json and the info was deleted as expected.
    It's safe to use that simple form even with this error?

    Code:
    [Oxide] 6:04 AM [Error] RotAG-LES: invalid arguments to method call
      at NLua.Lua.ThrowExceptionFromError (Int32 oldTop) [0x00000] in <filename unkn
    own>:0
      at NLua.Lua.CallFunction (System.Object function, System.Object[] args, System
    .Type[] returnTypes) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (ob
    ject,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
    Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
    ization.CultureInfo culture) [0x00000] in <filename unknown>:0
    
     
  6. That error is being caused by something else though, as it's stating "invalid arguments to method call". This most likely points to a method you're trying to call with the wrong arguments.
     
  7. That's weird... it only shows up if I simplify the method using your option. If I stick to the function tableRemoveKey that I've created, no errors are generated.
     
  8. Dont use the function at all.
    When you use LOCAL, the variable gets saved inside the cache, adding more and more local to the cache that Will never be used later on.
    just do table[value]=nil
    In your code, donc make à remove function that doesnt do anything Else then that.

    Also à little tip that i found out.
    It is impossible to do direcly:
    GroupData={}
    You need to delete all the tables inside the tables first
    GroupData.Testers.Leaders = nil
    GroupData.Testers.Members = nil
    Then
    GroupData.Testers=nil
    Then
    GroupData={}

    You can look inside my r-Zones how i did it ...
    It Hurt my Brain for days before i found out that
     
  9. What??? You can clear the data at any given point without having to clear data in that table first so to stick with your example, you can just clear Testers without clearing leaders and members before. Small code example here :) :
    Code:
         myTable = { ["Test1"] = { ["Leader"] = { "123456","mughisi" }, ["Members"] = { "321654", "isihgum" } }, ["Test2"] = { ["Leader"] = { "123456","mughisi" }, ["Members"] = { "321654", "isihgum" } } }
        print( "Table without modifications:" )
        tprint( myTable )
        print( " " )
        print( "Table after setting Test1 to nil" )
        myTable["Test1"] = nil
        tprint( myTable )
        print( " " )
        print( "Table after setting table to nil" )
        myTable = nil
        print( tostring( myTable ) )
    Output:
    Code:
    12:04 PM [Info] Table without modifications:
    12:04 PM [Info] Test1:  ( table )
    12:04 PM [Info]   Leader:  ( table )
    12:04 PM [Info]     1: 123456 (string)
    12:04 PM [Info]     2: mughisi (string)
    12:04 PM [Info]   Members:  ( table )
    12:04 PM [Info]     1: 321654 (string)
    12:04 PM [Info]     2: isihgum (string)
    12:04 PM [Info] Test2:  ( table )
    12:04 PM [Info]   Leader:  ( table )
    12:04 PM [Info]     1: 123456 (string)
    12:04 PM [Info]     2: mughisi (string)
    12:04 PM [Info]   Members:  ( table )
    12:04 PM [Info]     1: 321654 (string)
    12:04 PM [Info]     2: isihgum (string)
    12:04 PM [Info]  
    12:04 PM [Info] Table after setting Test1 to nil
    12:04 PM [Info] Test2:  ( table )
    12:04 PM [Info]   Leader:  ( table )
    12:04 PM [Info]     1: 123456 (string)
    12:04 PM [Info]     2: mughisi (string)
    12:04 PM [Info]   Members:  ( table )
    12:04 PM [Info]     1: 321654 (string)
    12:04 PM [Info]     2: isihgum (string)
    12:04 PM [Info]  
    12:04 PM [Info] Table after setting table to nil
    12:04 PM [Info] nil
     
  10. not if you want to save it in a file.
    try it out you will see ...
    took me 1 week to fix just this in r-Zones.
    deletion worked ONCE then all add/remove NEVER got saved in the file.
    it's a very strange bug, but you should try to use my r-zones, remove the part where i reset everything 1 by 1.
    and try adding 3 zones, then removing all of them 1 by 1, you will see in your data file that ONLY the FIRST one removed will be rmeoved from the datafile, and all the others will stay (until you reload the plugin and remove again, same thing will happen, first will get removed and the other ones wont)
     
  11. Hmm, reminds me of the issue in the beginning with the config files where you couldn't save a file with an empty table value :p. Appears that it does in fact not save, but it should to be honest so guess we'll need a fix for that issue :(
     
  12. yeah ... well now that we know it it's fine ...
    but it's just another example of why oxide 2 is harder to code then oxide 1.
    (and another example why it would be awesome to have a wiki for oxide 2 to help new coders)
     
  13. Correct if I'm wrong, but you are telling us that each LOCAL just increases the Cache and from what I understood, the more Cache the server have, more slow to response it will become.