Jump to content




os.run a function


  • You cannot reply to this topic
4 replies to this topic

#1 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

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?

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 09 February 2017 - 09:35 PM

setfenv and/or pcall

#3 houseofkraft

  • Members
  • 170 posts
  • LocationUSA

Posted 09 February 2017 - 09:56 PM

I don't get what you mean, could you please give me an example or something?

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 09 February 2017 - 11:03 PM

https://www.lua.org/...tml#pdf-setfenv
https://www.lua.org/....html#pdf-pcall

RTFM please.

pcall( setfenv( websites.test, getfenv(1) ) )


#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users