Retrogamecoding(.org) > Announcements

Chipmonkey Lua 0.2

(1/2) > >>

Cybermonkey:
Chipmonkey is an interactive Lua interpreter in the style of the good old days of BASIC. This was actually inspired by the classic Chipmunk BASIC by David Gillespie. I played around a bit but stumbled soon upon ome problems: since it uses inline 32 bit ASM it wasn't possible to compile for 64 bit Linux systems. And because my main working OS is a 64 bit Kubuntu that was a no go. So one day I thought, why not taking Lua for he task? The only thing which was a bit tricky to implement is the interactive mode because I have to check the input before executing if there's a for, while or repeat loop or an if statement. But, well, here it is: Chipmonkey 0.2 (see attached screenshots).

Cybermonkey:
Okay, I attached the Windows version so you can test it. Bear in mind that the edit mode is very rudimentary and the main (and fun) part is the interactive mode. Of course you can still edit the files with any text editor.
If you want to load an example do this:

--- Code: ---chdir "examples"
load "colourdots.lua"
run()
--- End code ---
You can examine the active directory with

--- Code: ---files "*"
--- End code ---
to list all files or

--- Code: ---files "*.lua"
--- End code ---
to list all Lua files.
Now have some fun with that. It reminds me on the old good old days of computing.

EDIT: If you don't know the 256 colour palette anymore, have a look at the attached image. (Colour values from 0-255)
That's the program for drawing the palette:

--- Code: ---graphic (1)
i=0
for y=0,480,30 do
for x=0,640,40 do
color (i)
fillrectangle (x,y,x+40,y+30)
i=i+1
end
end
inkey()
graphic (0)

--- End code ---

Tomaaz:
I don't know... I like Chipmonkey BASIC more, because Chipmonkey Lua looks like a poor version of EGSL (both are based on Lua and have additional features implemented). Chipmonkey BASIC is more old-school, has line numbers and a real BASIC syntax. If I want/need to write something in Lua I'd rather use EGSL or pure Lua interpreter.

Tomaaz:
I tried it under Wine on Linux and it works without any problems and quite fast. Do you remember this topic: http://forum.basicprogramming.org/index.php/topic,2222.0.html? Here is my Lua version:


--- Code: ---czas = (os.time())

plik = io.open("Bible.txt","r")
tekst = plik:read("*all")
io.close(plik)

zawartosc = string.lower(tekst)
wszystkie = {}
unikalne = {}
posortowane ={}
ilosc = 0

for x in string.gmatch(zawartosc, "%a+") do
if string.len(x) ~= 1 or x == "a" or x == "i"  then
ilosc = ilosc + 1
wszystkie[ilosc] = x
end
end

ilosc = 0
for x = 1, #wszystkie do
if not unikalne[wszystkie[x]] then
unikalne[wszystkie[x]] = 1
ilosc = ilosc + 1
else
unikalne[wszystkie[x]] = unikalne[wszystkie[x]] + 1
end
end

for x, y in pairs(unikalne) do
posortowane[#posortowane + 1] = y
end

table.sort(posortowane)

plik = io.open("words.txt", "w")
plik:write("All words: ", #wszystkie, "\n")
plik:write("Unique words: ", ilosc, "\n\n")
for x = #posortowane, 1, -1 do
for a, b in pairs(unikalne) do
if b == posortowane[x] then
plik:write(a, " - ", b, "\n")
unikalne[a] = nil
break
end
end
end
io.close(plik)

io.write("Done in ", os.time() - czas, " sec.\n" )

--- End code ---

On my laptop it takes 14 sec. to complete the task. The source code and a file with a result are attached.

Cybermonkey:
Some news abot this project. I think the screenshot will tell it all ...  ::)

Navigation

[0] Message Index

[#] Next page

Go to full version