Jump to content




Automaticly declare new functions in Lua prompt!

api lua

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

#1 qwerty

  • Members
  • 72 posts
  • LocationThe Sand Dunes

Posted 14 August 2018 - 12:57 PM

This is a simple way of integrating an API without actually having a separate file(except the mask file).

Why would you want this if you can just load APIs? - Well, let's suppose you have some simple functions like terminal clearing that aren't worth making an API but too much hassle to manually enter.

Well the simple solution to this would be to just make a file labeled 'lua' (for ease of differentiation or something).
The contents would look something like:
--[[this is a simple function to clear the terminal]]
function clear()
  term.clear()
  term.setCursorPos(1,1)
end

--[[another example]]
function betterClear(bool)
  if not bool then
	clear()
  else
	term.setBackgroundColor(colors.black)
	term.setForegroundColor(colors.white)
	clear()
  end
end


shell.run("rom/programs/lua.lua")

otherwise you can just put all that in an API and have a startup file with:
os.loadAPI(-name of API-)

But that creates some incompatibilities with other programs under certain circumstances but you can just simply edit the startup file.

-edited for a better tutoring experience-

Edited by qwerty, 10 June 2020 - 06:16 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users