Advertisement
Frekvens1

[OC] Problem loading files

Jan 4th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1.         -- .: WHAT I AM TRYING TO ACCOMPLISH :. --
  2.  
  3. Im trying to load a script into a variable which can display internal information
  4.  
  5.                  -- .: ERROR :. --
  6.  
  7. "/home/run.lua:2: attempt to index local 'test' (a function value)"
  8.  
  9.                   -- .: FIX :. --
  10.  
  11.           Change from 'loadfile' to 'dofile'
  12.             *Solved by IRC user 'payonel'*
  13.                  ^^ Thanks alot!! ^^
  14.  
  15.               -- .: FILES & CODE :. --
  16.  
  17. |-------------------------------------------------------|
  18. |                -- "/home/run.lua" --                  |
  19. |-------------------------------------------------------|
  20. | **local test = loadfile("/home/test.lua", "bt", _G)** |
  21. | local test = dofile("/home/test.lua", "bt", _G)       |
  22. | print(test.variable)                                  |
  23. |                                                       |
  24. |-------------------------------------------------------|
  25.  
  26.  
  27. |----------------------------------------------------|
  28. |               -- "/home/test.lua" --               |
  29. |----------------------------------------------------|
  30. | local test = {variable = "This is a test string"}  |
  31. | return test                                        |
  32. |                                                    |
  33. |----------------------------------------------------|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement