599 posts
Location
LeLua
Posted 30 August 2015 - 09:57 AM
One:
def centerText $default="Hello, world." then
:term_clear:
:term_setCursorPos termW/2 termH/2 :
:term_write $default :
end
:centerText:
:sleep 1 :
:centerText "Wow, Cool" :
Two:
local w, h = term.getSize()
addVar("termW", w)
addVar("termH", h)
addFunc("term_clear", function()
term.clear()
end)
addFunc("term_setCursorPos", function(input)
local x = tonumber(input[1])
local y = tonumber(input[2])
term.setCursorPos(x, y)
end)
addFunc("term_write", function(input)
local __str = ""
for i=1, #input do
__str = __str..input[i].." "
end
term.write(__str)
end)
addFunc("sleep", function(input)
sleep(tonumber(input[1]))
end)
This is a VM not a compiler.
And some pictures
Edited on 30 August 2015 - 08:59 AM
779 posts
Location
Kerbin
Posted 02 September 2015 - 11:13 AM
Looks very cool…
Edit: main thread/credits/download?
Edited on 02 September 2015 - 09:14 AM
599 posts
Location
LeLua
Posted 02 September 2015 - 04:13 PM
As I'm posting this, I made:
--variable declaration is a thing, but I'm doing this so you have the number to do the operations
$var = 10 -- 10
$var += 1 -- 11
$var -= 1 -- 10
$var *= 2 -- 20
$var /= 2 -- 10
--I don't know how modulus works YET
$var %= 5 -- I DUNNO
And they are done, well not completely but they are working when capturing.
Looks very cool…
Edit: main thread/credits/download?
Thanks.
Main thread: I will post it when I done 50% or more of it.
Credits: awesumber13 for the Idea of capturing and running functions. And ME and others that I forgot.
Download is not available.
Edited on 02 September 2015 - 02:19 PM
779 posts
Location
Kerbin
Posted 02 September 2015 - 05:23 PM
-your post-
It's php-like lol
$a = "b"
$b = "c"
: term_write $$a : --# will result "c"
I'm looking forward to try it or possibly include it in my OS i'm working on right now…
offtopic: Right now I'm trying to find a bug in my multitasking
Edited on 02 September 2015 - 03:23 PM
599 posts
Location
LeLua
Posted 02 September 2015 - 05:29 PM
how does:
$a = "b"
$b = "c"
:print $$a :
work?
And if you want, you can be my beta tester :D/>
779 posts
Location
Kerbin
Posted 02 September 2015 - 05:36 PM
In php the $ operator returns the value of the variable
$a returns b
But theres an other $ operator and b's value is c
Edit: I would be happy if i could test this :)/>/> but I don't have enough time :(/>/>
Edit2: suggestion:
Classes with Inheritence, Interfaces, Properties (get/set)
Edited on 02 September 2015 - 03:39 PM
599 posts
Location
LeLua
Posted 02 September 2015 - 05:39 PM
Ok i'll PM you with a pastebin and a demo.
779 posts
Location
Kerbin
Posted 02 September 2015 - 05:41 PM
Ok i'll PM you with a pastebin and a demo.
Ok, thanks! I'm sure that I'll find some free time for trying this!