Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. function refrence(path)
  2.     -- load up the refrence file
  3.     local refFile = compiler_load_rbf([[::simulation\attrib\refrence.rbf]])
  4.     local explodedPath = explode([[\]], path)
  5.    
  6.     local ref = refFile.GameData
  7.     local refT = refFile._TYPE.GameData
  8.    
  9.    
  10.     local returnT, TreturnT = {}, {}
  11.     for k,v in pairs(ref) do
  12.         returnT[k] = v
  13.     end
  14.     for k,v in pairs(refT) do
  15.         TreturnT[k] = v
  16.     end
  17.    
  18.    
  19.     for i = 1, table.getn(explodedPath) do
  20.         if type(ref[explodedPath[i]] == "table") then
  21.             ref = ref[explodedPath[i]]
  22.             refT = refT[explodedPath[i]]
  23.         else
  24.             print("false")
  25.         end
  26.     end
  27.    
  28.     return ref, refT
  29. end
  30.  
  31. function Shorten(file)
  32.     return file.GameData, file._TYPE.GameData
  33. end
  34.  
  35.  
  36. function insert_entry(path, openFile, info)
  37.     local exist = 0
  38.     for k,v in pairs(openFile[1]) do
  39.         if k == info[1] then
  40.             exist = exist + 1
  41.         end
  42.     end
  43.     local name
  44.     if exist > 0 then
  45.         -- also search for any un-compiled tables
  46.         while true do
  47.           name = [[&]] .. info[1] .. [[_]] .. exist
  48.           if not openFile[1][name] then
  49.               break
  50.           else
  51.               exist = exist + 1
  52.           end
  53.       end
  54.   else
  55.       name = info[1]
  56.   end
  57.  
  58.   openFile[1][name], openFile[2][name] = refrence(path)
  59.  
  60.   -- find out if we need to insert info into a table or just change a value
  61.   if table.getn(info) == 2 then
  62.       -- assosative entries do not show up, so it will be count 1 if there are assaocative entries
  63.       openFile[1][name] = info[2]
  64.   else
  65.       for k,v in pairs(info) do
  66.           if type(k) ~= "number" then
  67.               openFile[1][name][k] = v
  68.               if type(v) == "number" then
  69.                   openFile[2][name][k] = "int"
  70.               end
  71.           end
  72.       end
  73.   end
  74. end
  75.  
  76.  
  77.  
  78. function explode(div, str)
  79.     if (div=='') then return false end
  80.     local pos,arr = 0,{}
  81.     -- run for each divider found
  82.     for st,sp in function() return string.find(str,div,pos,true) end do
  83.         table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
  84.         pos = sp + 1 -- Jump past current divider
  85.     end
  86.     table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
  87.     return arr
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement