Tag360/Pages in progress/Window Graphical User Interface

From ComputerCraft Wiki
Jump to: navigation, search
This has been marked for deletion!
The content of this page is likely obsolete, duplicitous or irrelevant. You should not use or trust all information you see here.
(Reason: This is unfinished, poorly formatted and has not been edited for over a year and a half. The user is unlikely to return and complete it. Oeed 09:35, 25 March 2014 (GMT))

This is how you maks a Window based Graphical User Interface. You may want to finish the other tutorials before starting with this one. (This tutorial is not finished. Do not delete this page.)

Contents

Getting ready

Before you start, create a new program (I have called it "Window GUI"). Open it and use a text editor to edit it.

Step 1

Other stuff you may want

You may want to create a Disk for the GUI in Minecraft.

Making the Program

Now to make the Window GUI.

The basics

Make a loop at the end of the program's code. To make a while loop, use the code below:

while true do Your code goes here end

We will be using this loop to make it work.

Creating the windows

This is a Window based GUI, so you should make some window printing functions.

Here are 2 functions to write a small window that can be of any size, and a window that takes up the entire screen.

function PrintFullWindow(WindowName) local OldX,OldY = term.getCursorPos() FullScreenWindow = true local XWinSize, YWinSize = term.getSize() YWinSize = YWinSize - 2 local XPos, YPos = 1,1 local SizeX, SizeY = term.getSize() local CurXPosN = XPos local CurYPosN = YPos

term.setCursorPos(1,1) term.clearLine()

for CurX=1, XWinSize - 1 do --Write Bottom of TopBar term.setCursorPos(CurX + XPos - 1, YPos + 1) write("~") end

--Write the window's name term.setCursorPos(XPos, YPos) write(WindowName)

--Now write the window buttons term.setCursorPos(XPos + XWinSize - 8, YPos) write("|_|m|X|")

--Return the cursor to where it was orignally term.setCursorPos(OldX,OldY) end

function PrintWindow(XWinSize, YWinSize, XPos, YPos,WindowName) local OldX,OldY = term.getCursorPos() local CurXPosN = XPos local CurYPosN = YPos

for CurX=1, XWinSize - 1 do --Write TopBar term.setCursorPos(CurX + XPos - 1, YPos) write("_") --Write Bottom of TopBar term.setCursorPos(CurX + XPos - 1, YPos + 2) write("~") end

for CurY=1, YWinSize do --Write the sides of the window. term.setCursorPos(XPos, CurY + YPos) write("|") term.setCursorPos(XWinSize, CurY + YPos) write("|") end

--Write the Window's name term.setCursorPos(XPos + 1, YPos + 1) write(WindowName)

--Now write the window buttons term.setCursorPos(XPos + XWinSize - 9, YPos + 1) write("|_|[]|X|")

--Return the cursor to where it was orignally term.setCursorPos(OldX,OldY) end

The Graphical User Interface

Making it work

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox