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

[TOOL] MenuX - Custom scripting language [v1.1] - COLORS

Started by billysback, 07 November 2012 - 10:44 AM
billysback #1
Posted 07 November 2012 - 11:44 AM
MenuX uses my own scripting language (renamed "SLIMEBOL") to help you easily create menus etc. for CC.

It is run using the following syntax:

MenuX SCRIPTDIR

The Script Syntax/reference guide can be found here:
SpoilerDEF <varname> <value>
-defines or sets the var to that value

SET <varname> <value>
-sets the var to that value

API <dir>
-loads an API, APIs can override any of the area blocks.


DEL <varname>
-deletes the variable

PRS <name>
-runs the defined function

RUN <name> <variable>
-runs the program using shell.run()

RUNLN <line>
-runs that single line of code

DO <code>
-runs that defined bit of code

IF <vars to check> DO <code>
-if all the vars are equals to each other the code is run.

IFNOT <vars to check> DO <code>
-if none of the vars are equal to each other the code is run.

WHILE <vars to check> DO <code>
-while all of the vars are equal it loops the code

WHILENOT <vars to check> DO <code>
-while none of the vars are equal it loops the code

FOR <start> <end> <step> <code>
-for start to end, increasing by step, the code is run.

TABLE <CMD>
LEN <table> <var>
-sets the variable to the length of the table

SET <table> <index> <value>
-sets the value of the table at the index to the value indicated

GET <table> <index> <var>
-sets the var to the value at the index of the table indicated

EVENT <CMD>
TYPE <varname>
-sets the variable to the type of event

VAR <varname> <n>
-sets the variable to the nth event parameter

MATH <varname> <equation>
-sets the variable to the result of the equation

ART <CMD>
BACKGROUND <color> <x> <y>
-sets background of that x,y to the defined color

TEXT <color> <x> <y>
-sets text of that x,y to the defined color

COLOR (or COLOUR) <varname> <color>
-sets the varname to integer value of color

GET <varname> <x> <y>
-sets the varname to the color found at the x,y
-only works for colors set inside the script


TERM <CMD>
PRINT <value>
-prints that value on the screen

SIZE <w> <h>
-sets x and y to the width and height of the terminal

RESTORE
-restores the terminal (term.restore())

CLEARLN
-clears the line the cursor is currently on

BLINK
-toggles blinking

GETBLINK <varname>
-sets the varname to true/false depending on if blink is on/off

SCROLL <n>
-essentially term.scroll(n)

REDNET <CMD>
OPEN <side>
-opens that side of the computer

CLOSE <side>
-closes that side of the computer

ANC <side>
-effectivley rednet.announce()

SEND <id> <message>
-effectivley rednet.send(id, message)

CAST <message>
-effectivley rednet.broadcast(message)

RECIEVE <timeout> <table>
-effecivley rednet.recieve(), the returned vars are turned in to a table and table is set to that table.

WRITE <value>
-writes that value on the screen

SET <x> <y>
-sets the cursor to that position on the screen

SLEEP <t>
-sleeps for that amount of time

TIMER <t>
-starts a timer with t as the interval

STOP
-stops the program running

CLEAR
-clears the terminal

COMP <CMD>
TEXT <varname>
-sets the variable to the containing text of the component

TYPE <varname>
-sets the variable to the type of component

X <varname>
-sets the variable to the X of the component

Y <varname>
-sets the variable to the Y of the component

WIDTH <varname> (or W <varname>)
-sets the variable to the width of the component

HEIGHT <varname> (or H <varname>)
-sets the variable to the height of the component

SET <COMP CMD> <value>
-use above for comp commands, sets that value to the set value.

SETFUNC <name> <code>
-creates a new function called the set name contianing the code

STRING <CMD>
CONCAT <varname> <values>
-joins all of the values together and sets the variable to the result

CUT <varname> <value> <start> <end>
-effectivley string.sub(), should be self explanatory.

RPL <varname> <value> <from> <to>
-effectivley string.gsub(), should be self explanatory

SPLIT <varname> <value> <splitat>
-sets the variable to the split version of the value

ISPLIT <varname> <value> <splitat> <index>
-sets the variable to the index of ths split version of the value

IO <CMD>
CREATE <dir>
-creates a file at the directory

DELETE <dir>
-deletes a file at the directory

OPEN <dir> <type> <name>
-opens the file for use later on, type: write/read.

CLOSE <file>
-closes the file, file is the name set at OPEN

WRITE <file> <line>
-writes the line in the file

READ <file> <varname>
-the variable is set to the new line if it is not nil, it is set to false if it is nil

READF <file> <varname>
-the variable is set to a table containing every line of the file

* <name>
-starts a code block, * on it's own line will end the code block.


Variable rules:
Strings: "value"
Integer: #value
Boolean: %t/true/y/yes/f/false/n/no
Table: <value|value|value|value>
Variable: $varname

Code blocks:
* codename
<code>
*

Area blocks:
::
<area type>
<area code>
::

Area types:
start - run on startup
end - run on end
update - run every update
event - run every event
func:~:name - creates a function
comp - creates a component

Commenting out lines:
start it with ## to comment one line
#: on its own lines starts a comment block
:# on its own line ends a comment block

COMPONENTS DON'T WORK PROPERLY YET!

Update on events; every single event, even any custom or new ones, should work with a maximum of 3 arguments/parameters!


Area types:
start - run on startup
end - run on end
update - run every update
event - run every event
func:~:name - creates a function
comp - creates a component


Commenting out lines:
start it with ## to comment one line
#: on its own lines starts a comment block
:# on its own line ends a comment block

COMPONENTS DON'T WORK PROPERLY YET!

An example script can be found here:
Spoilerhttp://pastebin.com/CKiEXQEK
http://pastebin.com/Yqyq1xXk

MenuX can be found here:
Spoilerv1.0
http://pastebin.com/yexw7ynW
v1.1
http://pastebin.com/6Sj8B1Yh

Bidex Notepad++ syntax can be found here:
Spoilerv1.0
http://www.mediafire...f7gn815tg6xj4e6
v1.1
http://www.mediafire...f7gn815tg6xj4e6

Please feel free to post any suggestions, to either the program or the scripting language, also post any criticisms or support you wish to tell me!

Thanks!

(Sorry this post was rushed, I will be creating and posting a tutorial for Slimebol soon and inproving upon suggestions…)
Sammich Lord #2
Posted 08 November 2012 - 01:00 AM
Confusing.
billysback #3
Posted 08 November 2012 - 04:46 AM
What bit confuses you?
Mandrake Fernflower #4
Posted 08 November 2012 - 09:39 AM
Good work on the interpeter but there are two things I dont like about the scripting lang that is used:

1. The name sounds alot like bidet and well umm thats disturbing

2. IMHO the syntax is a mess. It looks like somthing that would be used on a PDP-11. It looks like a fusion of FORTH,Python and COBOL.
tommyroyall #5
Posted 08 November 2012 - 10:18 AM
I love it man, finally, a good alternative language :3.
billysback #6
Posted 08 November 2012 - 11:18 AM
Good work on the interpeter but there are two things I dont like about the scripting lang that is used:

1. The name sounds a lot like bidet and well umm thats disturbing

2. IMHO the syntax is a mess. It looks like somthing that would be used on a PDP-11. It looks like a fusion of FORTH,Python and COBOL.
I tried making a scripting language using Java a while back, and recently found it again (though this was not the inspiration for creating this) and started playing around with it a little bit, and remembered just how much I had done (but also why I had stopped; I had codded it in too much of a messy way to incorporate new things very easily, like I can with this). Anyway, I was thinking of a name and decided to name it Bidex because I liked that name last time and it was almost in memory of that one…

For the second part, there is not much I can do about the syntax, but there may be a way depending on what part you dislike, it would have to be done without forcing it upon people who want to use the normal syntax though…

I love it man, finally, a good alternative language :3.
Thanks for the support, means a lot to me :P/>/>

EDIT:
I searched "Bidex" in to google just now, and I'm not 100% sure what it does, but it doesn't look good… -.-
darkrising #7
Posted 08 November 2012 - 12:15 PM
hmm interesting :P/>/>
Mandrake Fernflower #8
Posted 08 November 2012 - 12:24 PM
EDIT: post expundged because I realized that it may have been profane
Mandrake Fernflower #9
Posted 08 November 2012 - 01:16 PM
Due to this lang looking a bit like COBOL. I think a good name would be SLIMEBOL. (Play on 'Slimeball')

because a name like bidex sounds alot like somthing that we should avoid :P/>/>
billysback #10
Posted 09 November 2012 - 07:55 AM
UPADTE:
-added art, lots of term commands.
Sammich Lord #11
Posted 09 November 2012 - 08:49 AM
The syntax seems very confusing. I like the Lua syntax. Why did you make such a complex syntax?
billysback #12
Posted 09 November 2012 - 08:55 AM
This was basically easier to code, that was essentially the only reason.

I am coding a game in it right now, as a simple example, to show off how you can do some things…
It wasn't a very long though decision, what the syntax would be, I just though should I use spaces or get rid of them, then I thought of complexities to do with defining strings whilst removing spaces and decided to use spaces as a separator…
tommyroyall #13
Posted 11 November 2012 - 01:08 PM
I do take a liking to this area-based paradigm of programming. Perhaps though stripping parts of this down and turning it into, say, MC-BASIC would draw a much larger crowd, and dispose of the Bidex name, sounds like Bidèt :unsure:/>/>. Perhaps give that MC-BASIC a run, or maybe with the typical line-numbering, like this:

10: PRINT 'Enter your name:'
20: READ $name, string
30: PRINT 'Hello $name'
bbqroast #14
Posted 11 November 2012 - 01:15 PM
So wait, you've created a language coded in another language within a game coded in yet another language?
Languageception!
Now all we need is a game written using MenuX (street fighters menu based addition!).