This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
houseofkraft's profile picture

os.run a function

Started by houseofkraft, 09 February 2017 - 08:15 PM
houseofkraft #1
Posted 09 February 2017 - 09:15 PM
Hello!

I am currently making a web browser and I need a custom environment to shrink the webpage by a few pixels. Here's an example on what I want


local websites = {
   test = function()
      setBG( colors.white )
   end
}

local env = getfenv(1)

os.run(env, websites.test)

How would I do something like this?
KingofGamesYami #2
Posted 09 February 2017 - 09:35 PM
setfenv and/or pcall
houseofkraft #3
Posted 09 February 2017 - 09:56 PM
I don't get what you mean, could you please give me an example or something?
KingofGamesYami #4
Posted 09 February 2017 - 11:03 PM
https://www.lua.org/manual/5.1/manual.html#pdf-setfenv
https://www.lua.org/manual/5.1/manual.html#pdf-pcall

RTFM please.


pcall( setfenv( websites.test, getfenv(1) ) )
Bomb Bloke #5
Posted 10 February 2017 - 07:05 AM
If I'm not misunderstanding, are you simply saying you want to run an external script in a slightly smaller terminal window? In that case, you should simply be able to redirect to a window before running that other script.