Jump to content




Text GUI API

api lua computer

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

#1 tuomas56

  • Members
  • 3 posts

Posted 18 February 2014 - 03:27 PM

I have created an api that allows you to create interactive text-based guis.

to get it run
pastebin get 1XX41eZ2 textgui

I cannot explain it very well so I will put an example usage:

-- this loads the api from file (change this to where you saved it)
os.loadAPI('textgui')

--this is the function that we pass to the runGui command to execute button actions if they do not take us to another window
function buttonPressed(s)
  if s == "quit" then
	 -- this is the command to quit the gui
	 textgui.endGui()
  end
end

-- this is the table which tells the api how to display the guy
local mopt = {
  -- each window has a separate table with an id
  [0] = {
	-- each item in the window has an id and inside it's table it has the text which is displayed and the y position on the item
	[1] = { "Window 1",3},
	--  and item with a id of ~ fills the line with -
	["~"] = 5,
	-- when an item is clicked it will go to the window with the id of the id of the item unless the item's id is a string in which case
	-- it will be handled by the function at the top which is passed to textgui.runGui
	["quit"] = { "Quit",7}
  },

  -- this is another window that the Window 1 button goes to because the ids are the same
  [1] = {
  -- and this will take you back to the original window
  [0] = {"Back",2}
  },

}
textgui.runGui(mopt,buttonPressed)
Screenshots:
Posted Image
Posted Image

Edited by tuomas56, 03 June 2014 - 08:08 PM.


#2 joebodo

  • Members
  • 69 posts

Posted 19 February 2014 - 07:32 AM

os.loadAPI('textgui')textgui.runGui({[0]={[1]={"W",3},["~"]=5,["q"]={"Q",7} },[1]={[0]={"B",2}},} ,function(s)if s=="q" then textgui.endGui() end end)

A multipage GUI all on 1 line

Edited by joebodo, 19 February 2014 - 07:33 AM.


#3 tuomas56

  • Members
  • 3 posts

Posted 28 February 2014 - 05:48 PM

View Postjoebodo, on 19 February 2014 - 07:32 AM, said:

os.loadAPI('textgui')textgui.runGui({[0]={[1]={"W",3},["~"]=5,["q"]={"Q",7} },[1]={[0]={"B",2}},} ,function(s)if s=="q" then textgui.endGui() end end)

A multipage GUI all on 1 line

Cool! I never thought about using it like that...

#4 RoD

  • Members
  • 313 posts

Posted 30 March 2014 - 08:54 AM

Screenies? I would like to see how the GUI is and how does it look like before testing it myself.

#5 tuomas56

  • Members
  • 3 posts

Posted 03 June 2014 - 08:10 PM

View PostRoD, on 30 March 2014 - 08:54 AM, said:

Screenies? I would like to see how the GUI is and how does it look like before testing it myself.
Added Screenshots





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users