Jump to content

minor bug in lua RunScript()


Go to solution Solved by Josh,

Recommended Posts

Posted

currently on beta `RunScript("")` always returns nil.  I was kinda expecting it to return a table wrapping dofile or such, but looked at docs and saw returning boolean for if the script is ran. that is fine and useful, but if I'm running a script i'm almost always digging/updating state out after as well so it got me thinking, (here's an example of how im currently working around no bool as well):

_G["results"] = nil
local ret = RunScript("example.lua")  -- `results = {1,2,3}`
-- ret is always nil

local lv = _G["results"]
local set = lv ~= nil

if set then
   -- ran ok and global pushed, go use it ...
end

I reckon it would be useful to return some sort of value, a table or expected value or something? or some pattern/system for getting its value or state? I assume in lua projects there is only one lua state though?  If not a bool is fine too, this is a bit specific to my hotloading ui :)

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...