Posted 14 August 2014 - 08:54 PM
MobGui Gui Api
What is this Api ?
This api is meant to create easy gui in your programs.
How to install / use in your programs ?
Method 1 - The MobGui method
Just put these 3 lines i front of your code if you are running your program on a computer where you got MobGui installed:
Method 2 - The Pastebin Method
Put these 4 lines in front of your code :
How to use the Api in your programs ?
The base principle is that you have a GuiContext where you add your objects. The GuiContext can be a monitor peripheral or the term on your computer.
How to create a GuiContext :
And so to use :
Thats the base of your Gui. Now how to create Gui elements like a button:
And so to use:
First, your click callback with an optional parameter : a position bundle
The options in the position bundle:
relX, relY - the coordinates relative to the start x and y of the button
absX, absY - the absolute coordinates on the screen
Then, the button creation.
Last, adding the button to the gui context.
Now another Gui object, the Label:
You may were now thinking of, how the buttons get on the screen o.O ?
There are two ways to go with:
Method 1 - Just draw it
You can notify the GuiContext to draw the objects to the screen:
Method 2 - Listen for events to interact with the objects:
There are several other components. I will create a complete list when I have time on my website. I will post a link here where you can find the documentation.
If you wonder what MobGui is, check out my website for more information about it:
The Project page : https://ccmob.net
The blog with updates and little example scripts : http://blog.ccmob.net
I hope you like this api, or not …
Anyways … If you have some improvements, post it on my website or here in this thread.
Sorry for the not so good looking post, i will try to improve the design of this post from time to time ^^
MinecraftM0b
What is this Api ?
This api is meant to create easy gui in your programs.
How to install / use in your programs ?
Method 1 - The MobGui method
Just put these 3 lines i front of your code if you are running your program on a computer where you got MobGui installed:
executeCommand("runWebProgram http://gui.cc.ccmob.net/add.msx")
executeCommand("install gui")
executeCommand("gui")
Method 2 - The Pastebin Method
Put these 4 lines in front of your code :
if fs.exists("gui-fetch.lua") then fs.delete("gui-fetch.lua") end --optional
shell.run("pastebin", "get", "mFCCmmZd", "gui-fetch.lua")
if fs.exists("gui-fetch.lua") then shell.run("gui-fetch.lua") else error("Gui api not found.") end
if fs.exists("gui.msx") then shell.run("gui.msx") end
How to use the Api in your programs ?
The base principle is that you have a GuiContext where you add your objects. The GuiContext can be a monitor peripheral or the term on your computer.
How to create a GuiContext :
CreateGuiContext(termContext, isMonitorContext)
Note: The isMonitorContext parameter is optional.And so to use :
local gui = CreateGuiContext(term)
Thats the base of your Gui. Now how to create Gui elements like a button:
GuiButton(x,y,foreGround,backGround,text,onClickMethod)
And so to use:
function onBlueButtonClick() print("You clicked me :P/>/>/>/>") end
local button = GuiButton(2,2,colors.white, colors.blue, "A blue button", onBlueButtonClick)
gui.add(button)
First, your click callback with an optional parameter : a position bundle
The options in the position bundle:
relX, relY - the coordinates relative to the start x and y of the button
absX, absY - the absolute coordinates on the screen
Then, the button creation.
Last, adding the button to the gui context.
Now another Gui object, the Label:
GuiLabel(x,y,foreGround,backGround,text)
local label = GuiLabel(2,2,colors.gray, colors.black, "A label o.O")
gui.add(label)
You may were now thinking of, how the buttons get on the screen o.O ?
There are two ways to go with:
Method 1 - Just draw it
You can notify the GuiContext to draw the objects to the screen:
yourGuiContext.draw(clearTerm)
Note: clearTerm - true/false and optionalMethod 2 - Listen for events to interact with the objects:
yourGuiContext.listen()
This function waits for any os event. It checks if it is any monitor or mouse input and checks the position and matches it with the buttons if clicked and notify the gui objects if they were clicked.There are several other components. I will create a complete list when I have time on my website. I will post a link here where you can find the documentation.
If you wonder what MobGui is, check out my website for more information about it:
The Project page : https://ccmob.net
The blog with updates and little example scripts : http://blog.ccmob.net
I hope you like this api, or not …
Anyways … If you have some improvements, post it on my website or here in this thread.
Sorry for the not so good looking post, i will try to improve the design of this post from time to time ^^
MinecraftM0b