Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
sirdabalot

OpenComputers GUI FrameWork v0.1

Recommended Posts

https://github.com/sirdabalot/OCGUIFramework

 

Hello everyone! This is my first API post so go easy on me. =P

This is an OpenComputers GUI framework, its currrent features are:

  1. Movable Windows
  2. Buttons
  3. Textboxes
  4. Text inputs

This is my new GUI framework API, designed to be simple as possible.

 

Simply require the lua file into your program and start using the functions.

 

Method information can be found on the readme on the github page.

 

By the way windows can be moved by clicking the # in the top left corner, also note that after you've entered text into a textInput you must press enter.

 

Example code:

 

This code was to be used with the mekanism teleporters.

 
require( "SOCGUIF" )
term = require( "term" )
components = require( "component" )

tele = components.teleporter
gpu = components.gpu

function setTeleCus( )
	code = codeIn.text
	for i = 0, 3 do
		tele.set( i, tonumber( string.sub( code, i+1, i+1 ) ) )
	end
end

function setTeleP1( )
	code = "0001"
	for i = 0, 3 do
		tele.set( i, tonumber( string.sub( code, i+1, i+1 ) ) )
	end
end

function setTeleP2( )
	code = "0002"
	for i = 0, 3 do
		tele.set( i, tonumber( string.sub( code, i+1, i+1 ) ) )
	end
end

function exitProg( )
	gpu.setBackground( 0x000000 )
	gpu.setForeground( 0xFFFFFF )
	term.clear( )
	os.exit( )
end

controlPanelWindow = window( point( 120, 3 ), 18, 6, "Control panel", 0xFFFFFF, 0x00FF00 )
exitButton = button( controlPanelWindow, point( 2, 2 ), 15, 3, "Exit", 0xFFFFFF, 0xFF0000, exitProg )

customTeleWindow = window( point( 3, 3 ), 22, 9, "Custom teleport", 0xFFFFFF, 0x00FF00 )
codeInTB = textBox( customTeleWindow, point( 2, 2 ), #"Custom code:", 1, "Custom code:", 0xFFFFFF, 0xFF0000 )
codeIn = textInput( customTeleWindow, point( 1, 3 ), 19, 0xFFFFFF, 0xFF0000 )
customTeleButton = button( customTeleWindow, point( 2, 5 ), 19, 3, "Set", 0xFFFFFF, 0xFF0000, setTeleCus )

presetTeleWindow = window( point( 3, 17 ), 22, 10, "Preset teleport", 0xFFFFFF, 0x00FF00 )
customTeleButton1 = button( presetTeleWindow, point( 2, 2 ), 19, 3, "To portal 1", 0xFFFFFF, 0xFF0000, setTeleP1 )
customTeleButton2 = button( presetTeleWindow, point( 2, 6 ), 19, 3, "To portal 2", 0xFFFFFF, 0xFF0000, setTeleP2 )

table.insert( windowTable, customTeleWindow )
table.insert( windowTable, controlPanelWindow )
table.insert( windowTable, presetTeleWindow )

GUILoop( 0x0000FF )

Result in attached file...

 

 

post-558-0-92856600-1420316781_thumb.png

Link to post
Share on other sites

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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.