This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Symmetryc's profile picture

[Symmetryc's Programs] New XUtils API!

Started by Symmetryc, 05 April 2013 - 11:10 AM
Symmetryc #1
Posted 05 April 2013 - 01:10 PM
Symmetryc's Programs and APIs, enjoy!

X [WIP] [Game] [V0.4]

An RPG game I'm working on…it's going to take awhile for me to finish this.
SpoilerCode (All Versions):
V0.4 http://pastebin.com/0QXxXWuZ
V0.3 http://pastebin.com/mNN4KzHx
V0.2 http://pastebin.com/CqZGwt7S
V0.1 http://pastebin.com/Mc9zJfhU

Video (V0.5):
[media]http://www.youtube.com/watch?v=v__LDegx6Jk[/media]

How to get (Latest Version):


>pastebin get 0QXxXWuZ X

XUtils [API] [V1.2]

An API I'm working on, will help with X.
SpoilerCode (All Working Versions):
V1.2: http://pastebin.com/PAiYZRuZ
V1.1: http://pastebin.com/Z05xWxyJ

Demonstrations (Latest Version):
1. "Clear" Background
Spoiler

Documentation (Latest Version):
xutils.init()
SpoilerUse this to inititialize your screen for modification.

Arguments:
None.

Returns:
tScreen = xutils.init()
tScreen = your initialized screen variable.

Example Usage:
tScreen = xutils.init()
xutils.text(tScreen, "Hi", 1, 1, colors.red)
xutils.render(tScreen)

Note:
Unless you are experienced with handling more than one screen, make
sure to use the variable that you initialized your screen with all
of your xutils functions in that program.
function extract(tColors, …)
_ = {}
for i=1, 3 do _ = string.sub(tColors[arg[1]][arg[2]], i, i) end
return _[1], _[2], _[3]
end
xutils.extract()
SpoilerUse this to extract and interpret data from any pixel of your initialized
screen variable.

Arguments:
xutils.extract(tScreen, x, y)
tScreen = your initialized screen variable.
x = x-coordinate of the extraction pixel.
y = y-coordinate of the extraction pixel.

Returns:
background_color, text_color, text = xutils.extract(tScreen, x, y)
background_color = background color of that pixel.
text_color = text color of that pixel.
text = text that is on that pixel.

Example Usage:
tScreen = xutils.init()
_, _, text = xutils.extract(tScreen, 1, 1)
print('The text that is on pixel (1, 1) is "'..text..'"')

Note:
The values of the background and text colors are in Hexadecimal and 2 is
not put to the power of them.
This does not actually alter the values, it just returns them.
If your screen was just initialized, your text and background colors will
be white and the text will be " ".
xutils.insert()
SpoilerUse this to insert data into any pixel of your initialized screen variable.

Arguments:
xutils.insert(tScreen, text, text_color, background_color, x, y)
tScreen = your initialized screen variable.
text = text you are putting in.
text_color = text color of your text.
background_color = background color of the pixel.
x = x-coordinate of the pixel.
y = y-coordinate of the pixel.

Returns:
nil.

Example Usage:
tScreen = xutils.init()
xutils.insert(tScreen, "-", e, 6, 1, 1)
xutils.render(tScreen)

Note:
The values of the background and text colors must be in Hexadecimal and
2 should not be put to the power of them.
xutils.text()
SpoilerEquivalent of "write()" in the XUtils API.

Arguments:
xutils.text(tScreen, text, x, y, [text_color, background_color])
tScreen = your initialized screen variable.
text = what you are writing.
x = x-coordinate of the start of the text.
y = y-coordinate of text.
text_color = text color of the text, nil if the text will adopt the
text color that is already in the pixel(s).
background_color = background color of the text, nil if the text
will adopt the background color that is already in the pixel(s).

Returns:
nil.

Example Usage:
tScreen = xutils.init()
xutils.text(tScreen, "Hello World", 1, 1, colors.red)
xutils.render(tScreen)

Note:
Will error if the string is too long to be portrayed within a 51 by 19
pixel space, given the x and y arguments of the function.
xutils.color()
SpoilerPixel/Rectangle drawer, the main method of background color manipulation
in the XUtils API.

Arguments:
xutils.color(tScreen, background_color, x1, y1, [x2, y2])
tScreen = your initialized screen variable.
background_color = color of what you're drawing.
x1 = x-coordinate of the pixel/corner of the rectangle.
y1 = y-coordinate of the pixel/corner of the rectangle.
x2 = x-coordinate of the opposite corner of the rectangle.
y2 = y-coordinate of the opposite corner of the rectangle.

Returns:
nil.

Example Usage:
tScreen = xutils.init()
xutils.color(tScreen, colors.red, 1, 1, 5, 5)
xutils.render(tScreen)

Note:
Will error if any of the x-coordinates are not within 1 to 51 and if
any of the y-coordinates are not within 1 to 19.
xutils.render()
SpoilerRenders the initialized screen variable onto the screen.

Arguments:
xutils.render(tScreen)
tScreen = your initialized screen variable.

Returns:
nil.

Example Usage:
tScreen = xutils.init()
xutils.text(tScreen, "Rendered stuffs", 1, 1)
xutils.render(tScreen)
xutils.unload()
SpoilerUse this to save screen variables in files.

Arguments:
xutils.unload(tScreen, path)
tScreen = your initialized screen variable.
path = file you want to save the screen variable to.

Returns:
nil.

Example Usage:
tScreen = xutils.init()
xutils.unload(tScreen, "MyBlankFile")
xutils.load()
SpoilerUse this to initialize a screen variable from a file.

Arguments:
xutils.load(path)
path = file your screen is saved on.

Returns:
tScreen = xutils.load()
tScreen = your initialized screen variable.

Example Usage:
tScreen = xutils.load(CatPicture)
xutils.render(tScreen)

How to get (Latest Version):


>pastebin get PAiYZRuZ xutils
>lua
Interactive Lua prompt.
Call exit() to exit.
lua>os.loadAPI("xutils")
lua>exit()

Feedback is very much appreciated on any of the above! Thanks :D/>.
Bubba #2
Posted 05 April 2013 - 01:22 PM
Your video is private so we can't watch it!

And also your code isn't working. You didn't define the "window" function. Nice scrolling option menu/GUI though :)/> For your third program the GUI is damn good.
Symmetryc #3
Posted 05 April 2013 - 01:29 PM
Your video is private so we can't watch it!

And also your code isn't working. You didn't define the "window" function. Nice scrolling option menu/GUI though :)/> For your third program the GUI is damn good.
Yeah, only the "Options" part of the ToolBar is working and nothing else :/. Sorry.

Edit: OK, it's public now :D/>.
spyman68 #4
Posted 05 April 2013 - 02:29 PM
This looks really impressive!
Symmetryc #5
Posted 05 April 2013 - 03:57 PM
This looks really impressive!
Thanks, although it doesn't really have content :/.
nitrogenfingers #6
Posted 06 April 2013 - 02:18 AM
The interface is very nice. I'd suggest, rather than having a confirm dialogue for changes to the colour scheme, simply immediately applying those changes as the user makes them. This allows them to choose a colour scheme and experiment with one they like, rather than having to constantly test for an effective combination by going in and saving changes. Besides that, very clean and well thought out- hope the game itself is just as polished :)/>
remiX #7
Posted 06 April 2013 - 04:46 AM
Errors with anything I click.
After downloading and running once, errors with File not found
Symmetryc #8
Posted 06 April 2013 - 11:00 AM
The interface is very nice. I'd suggest, rather than having a confirm dialogue for changes to the colour scheme, simply immediately applying those changes as the user makes them. This allows them to choose a colour scheme and experiment with one they like, rather than having to constantly test for an effective combination by going in and saving changes. Besides that, very clean and well thought out- hope the game itself is just as polished :)/>
Hey NitrogenFingers (Love your YouTube Channel)! Thanks for the suggestion, I'll try to add it as soon as I can. Thanks for the feedback!
Errors with anything I click.
After downloading and running once, errors with File not found
Yeah, it's still in WIP, so only "[Options]" work at the moment, but I'm working on it today and will hopefully get the whole Toolbar to work soon. Although I'm not sure about the File not found thing, could you show me what you mean? Thanks for the feedback!

Edit: I found the File Error thing working on a fix.
Fixed, Thank you sir!
Dlcruz129 #9
Posted 06 April 2013 - 06:29 PM
Nice interface!
TheOddByte #10
Posted 07 April 2013 - 01:10 AM
This looks nice but as remiX says nothing works..
Looks great anyway! :D/>
Symmetryc #11
Posted 07 April 2013 - 02:28 AM
This looks nice but as remiX says nothing works..
Looks great anyway! :D/>
Yeah, sorry, I'm nearly done with the Toolbar and I when I'm done I'll update, as for the actual game content, I'm not sure when that'll be out. Right now I'm having my final exams coming up (Middle School *sigh* :/) so I won't have a lot of time, but I'll hopefully will have at least some of it done by the end of the month. Thanks for the feedback!
Nice interface!
Thanks! :)/>
TheOddByte #12
Posted 07 April 2013 - 04:54 AM
By the way.. What is the actual game content?
Since I would love to see it, And if it looks as great as this menu It'll be great! :D/>
Symmetryc #13
Posted 07 April 2013 - 05:54 AM
By the way.. What is the actual game content?
Since I would love to see it, And if it looks as great as this menu It'll be great! :D/>
It's like Fire Emblem and that Final Fantasy tactic thing. You're a character that can move around (like an RPG) and you have quests and stuff and you can also battle. Hopefully I'll get it done soon.

Edit: I didn't see anywhere in the rules that we can't double post, but just in case I've missed something, I'm just editing this post saying V0.3 is out and now the full Toolbar works, now I'm going to start work on the actual game…

Edit2: Oh yeah, and I'm going to add in NitrogenFinger's suggestion.

Edit3: Almost forgot, It may strike you as weird that there is nothing under controls, but that is simply because the content isn't done and there are no controls! :P/>.
remiX #14
Posted 07 April 2013 - 06:59 AM
Ooh the options are nice!
Nice works :P/>

Now to get the actual rpg mechanics to work :P/>
Symmetryc #15
Posted 08 April 2013 - 03:59 AM
Ooh the options are nice!
Nice works :P/>

Now to get the actual rpg mechanics to work :P/>
Thanks! I'm working on the RPG Mechanics, but I'm prioritizing the menus because I want everything to be polished and I don't want to do things half-heartedly :P/>.

Oh yeah and V0.4 is done! I've added NitrogenFinger's request sort-of. If I would've made it update in real time, not only will you not get to experience neither the animations nor the "Button Color", but it will also cause flickering with each click, so I opted for a "Preview" Tab. You can click it and it will preview the Main Menu with your colors and you can compare you're previous animations/colors with your new ones. I've also fixed up an animation speed bug where "Very Fast" and "Fast" speeds weren't working properly.
theoriginalbit #16
Posted 08 April 2013 - 04:12 AM
This GUI is pure beauty! I do not agree with this statement:
It's probably not that good compared to some of the other content on the forums
I would actually say that imo this IS the best GUI on the forums, especially for your 3rd program!
Code wise there are a few things that could make your life easier and the code a little cleaner, but never the less, the aesthetics is brilliant!
Symmetryc #17
Posted 08 April 2013 - 04:26 AM
This GUI is pure beauty! I do not agree with this statement:
It's probably not that good compared to some of the other content on the forums
I would actually say that imo this IS the best GUI on the forums, especially for your 3rd program!
Code wise there are a few things that could make your life easier and the code a little cleaner, but never the less, the aesthetics is brilliant!
Thank you very much for the kind remarks :)/>, but don't be impressed as I must note that this is my 3rd program in Lua, I've been making programs in other languages for a bit over 2 years now :P/>. As for the code, I know I don't use many contemporary methods such as acknowledging the existence of text/paintutils or using # in place of string.len or using those fancy shortcut functions with colons in them, but that's simply because the YouTuber I watched to learn Lua did those things that way and I haven't been able to break the habit :/.
theoriginalbit #18
Posted 08 April 2013 - 04:39 AM
but don't be impressed as I must note that this is my 3rd program in Lua
Third program in Lua or not, it is still impressive, there have been several other people on these forums saying that they program in other languages, not many of them produce anything with good quality GUIs like this.

As for the code, I know I don't use many contemporary methods such as acknowledging the existence of text/paintutils or using # in place of string.len or using those fancy shortcut functions with colons in them, but that's simply because the YouTuber I watched to learn Lua did those things that way and I haven't been able to break the habit :/.
Fair enough, but they were not the things I were referring to, its was more to do with using Objects and onClick handlers and such as opposed to having that whole 'if else' for all the guis. makes life much easier!
Symmetryc #19
Posted 08 April 2013 - 04:49 AM
Fair enough, but they were not the things I were referring to, its was more to do with using Objects and onClick handlers and such as opposed to having that whole 'if else' for all the guis. makes life much easier!
So like instead of having the menu() function, just have it write the menus in the the input() function? So that I don't have to go through all of the "if else"s of the menu() function in the input() function?
Shnupbups #20
Posted 13 April 2013 - 06:14 PM
Oh my god. This… oh my god.
Symmetryc #21
Posted 14 April 2013 - 06:28 AM
Oh yeah, a quick update on this, Im probably not going to be updating it in awhile, I've had the main menu done for awhile now with animated drop down menus that let you rename, delete, and copy your files to other files, but then I realized what a horrendous piece of junk the code is and Im going to rewrite it now. I may release 0.5 on Sunday though.
wilcomega #22
Posted 14 April 2013 - 10:47 AM
very nice and lovely gui :3
Symmetryc #23
Posted 15 April 2013 - 10:24 AM
very nice and lovely gui :3
Thank you very much, however if you think that this is good, you should really look at some cool windowed programs that others have made with far better looks than this, such as PearOS and Canvas. :)/>.
Edit: Oh, yeah and I added a poll. And just to let you guys know, I'm working on an API that will help with rendering right now, so after I push the 0.5 update, I will have to take a break, rewrite it, finish the renderer, and then I an start on the actual content, sorry, :(/>.
Symmetryc #24
Posted 15 April 2013 - 04:00 PM
Alright, I've got the V0.5 video up, however there are a couple of bugs, so I'm just going to not pastebin it until the rewrite is over.

Edit, OK, the API I've been working on has now been uploaded, it's not very useful yet, but there is a lot in the planning! Please leave feedback! Thanks :D/>.
Symmetryc #25
Posted 17 April 2013 - 11:11 AM
Update:
I've now changed the whole thread design to account for everything that I have.

Also, there was major bug in XUtils, so I just edited to V1.1 and took the download down for the old version, nobody wants to download broken code :P/>.

Edit: OK, I have a demonstration video up for XUtils, it doesn't really show off much, but I just wanted to have at least some content up for it.
Lyqyd #26
Posted 06 June 2013 - 12:43 PM
Locked by request.