Please log in to view the forum threads.

Be warned, NEVER give your account details to anyone!
Double accounts are unwanted and strictly prohibited!

If your account got hacked please immediately report this to the following Discord id's: Pr0Master#7146 or Snake#0582

You can join our DISCORD support group by using the following link:

Your Infinity Team

    Lua Memory


    Posts : 55
    Points : 75
    Likes : 6
    Age : 21
    Country : Chile/Santiago
    Join date : 2013-05-04

    Lua Memory

    Post by Starkkz on Fri Feb 28, 2014 2:56 am

    I just managed to make a RAM to HDD memory, it's still unstable because I made it in some minutes.

    - Every variable you set on the global table will be saved, incluiding sub tables memory

    - The script saves the HDD memory only when a variable in the global environment is modified. The only way I could fix this is by synchronizing the global table with the modified memory in sub tables, this subtables will need a source value to know where it is placed in the global environment.


    EnvironmentMetatable = {}

    function GetGlobal()
      local f ="Env.txt", "r")
      if f then
        local TableString = f:read("*a")
        local Table = string.totable(TableString)
        return Table or {}
      return {}

    function SaveGlobal(T)
      local f ="Env.txt", "w")
      if f then
        local TableString = table.serialize(T)
        return true
      return false

    function EnvironmentMetatable:__newindex(Key, Value)
      local SavedGlobal = GetGlobal()
      if self[Key] then
        setmetatable(self, nil)
        self[Key] = Value
        setmetatable(self, EnvironmentMetatable)
      elseif SavedGlobal then
        rawset(SavedGlobal, Key, Value)

    function EnvironmentMetatable:__index(Key)
      setmetatable(self, nil)
      local Value = self[Key]
      setmetatable(self, EnvironmentMetatable)
      if Value then
        return Value
      local SavedGlobal = GetGlobal()
      return rawget(SavedGlobal, Key)

    function serializeElement(object)
      if type(object) == "string" then
        return string.format("%q", object)
      elseif type(object) == "number" then
        return tostring(object)
      elseif type(object) == "table" then
        return table.serialize(object)
      elseif type(object) == "function" then
        local Success, Dump = pcall(string.dump, object)
        if Success then
          return "loadstring(\""..Dump.."\")"

    function table.serialize(t)
      if not t then return nil end
      local Elements = {}
      for k, v in pairs(t) do
        local Key = serializeElement(k)
        local Value = serializeElement(v)
        if Key and Value then
          table.insert(Elements, "["..Key.."]="..Value)
      return "{"..table.concat(Elements, ",").."}"

    function string.totable(s)
      return loadstring("return "..s)()
    setmetatable(_G, EnvironmentMetatable)

    I will probably add this on my admin script to make memory optimization tricks for computers with low ram.

      Current date/time is Sat Dec 15, 2018 7:53 pm