Improvements...III
This commit is contained in:
parent
ae1bb53004
commit
602c3f947c
@ -3,3 +3,10 @@
|
|||||||
graphed is a simple tool to create _ascii art_
|
graphed is a simple tool to create _ascii art_
|
||||||
It is very rudimentary for now...
|
It is very rudimentary for now...
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
- Version 0.2
|
||||||
|
- *WIP*
|
||||||
|
- Version 0.1
|
||||||
|
- added file write/load
|
||||||
|
-
|
||||||
|
|
||||||
|
91
main.lua
91
main.lua
@ -2,13 +2,11 @@
|
|||||||
nc = require("nocurses")
|
nc = require("nocurses")
|
||||||
dofile("simplefuncs.lua")
|
dofile("simplefuncs.lua")
|
||||||
-- Misc nc funcs ============================
|
-- Misc nc funcs ============================
|
||||||
|
|
||||||
COLORS={"BLACK","RED","GREEN","YELLOW","BLUE","MAGENTA","CYAN","WHITE"}
|
COLORS={"BLACK","RED","GREEN","YELLOW","BLUE","MAGENTA","CYAN","WHITE"}
|
||||||
MSIZE_X=32 -- Map
|
MSIZE_X=32 -- Map
|
||||||
MSIZE_Y=24 ---- size
|
MSIZE_Y=24 ---- size
|
||||||
PL_GLYPH="@"
|
PL_GLYPH="@"
|
||||||
VER=0.08
|
VER=0.10
|
||||||
-- MAKE Map matrix -------------
|
|
||||||
-- -------------- START FUNC -----------
|
-- -------------- START FUNC -----------
|
||||||
function start()
|
function start()
|
||||||
nc.setcurshape("BAR")
|
nc.setcurshape("BAR")
|
||||||
@ -17,7 +15,7 @@ function start()
|
|||||||
map=mkmat()
|
map=mkmat()
|
||||||
mapcolors=mkmat()
|
mapcolors=mkmat()
|
||||||
p=mkpointer()
|
p=mkpointer()
|
||||||
|
nc.clrscr()
|
||||||
-- Now main loop
|
-- Now main loop
|
||||||
main()
|
main()
|
||||||
end
|
end
|
||||||
@ -33,7 +31,12 @@ function drawmap()
|
|||||||
end
|
end
|
||||||
-- XXX draw last info line XXX
|
-- XXX draw last info line XXX
|
||||||
nc.gotoxy(0,MSIZE_Y+1)
|
nc.gotoxy(0,MSIZE_Y+1)
|
||||||
print("X:"..p.x.." | ".." Y:"..p.y.." ")
|
print("X:"..p.x.." | ".." Y:"..p.y.." ")
|
||||||
|
if mesg_string~=nil then
|
||||||
|
nc.gotoxy(1,1)
|
||||||
|
print(mesg_string)
|
||||||
|
mesg_string=nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawmap_fg() -- Draw map foreground
|
function drawmap_fg() -- Draw map foreground
|
||||||
@ -42,18 +45,20 @@ function drawmap_fg() -- Draw map foreground
|
|||||||
print(p.glyph)
|
print(p.glyph)
|
||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("WHITE")
|
||||||
end
|
end
|
||||||
----------- main func -----
|
-- end drawmap--> main func ---------VVVVVVVVV
|
||||||
function main()
|
function main()
|
||||||
printul("Graphed")
|
printul("Graphed -- 'Graphical Editor' --")
|
||||||
print("version "..VER)
|
printcol("http://asciibene.tx0.org/","YELLOW")
|
||||||
|
printcol("version "..VER,"CYAN")
|
||||||
while exitbool~=true do
|
while exitbool~=true do
|
||||||
if await_cmd()~=0 then
|
if await_cmd()~=0 then
|
||||||
drawmap()
|
drawmap()
|
||||||
drawmap_fg()
|
drawmap_fg()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
printul("Goodbye...")
|
printul("Goodbye...")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -64,17 +69,25 @@ function await_cmd()
|
|||||||
k=string.char(nc.getch())
|
k=string.char(nc.getch())
|
||||||
if k=="h" and p.x>1 then
|
if k=="h" and p.x>1 then
|
||||||
movep(-1,0)
|
movep(-1,0)
|
||||||
elseif k=="j" and p.y<=MSIZE_Y then
|
elseif k=="j" and p.y<MSIZE_Y then
|
||||||
movep(0,1)
|
movep(0,1)
|
||||||
elseif k=="k" and p.y>1 then
|
elseif k=="k" and p.y>1 then
|
||||||
movep(0,-1)
|
movep(0,-1)
|
||||||
elseif k=="l" and p.x<MSIZE_X then
|
elseif k=="l" and p.x<MSIZE_X then
|
||||||
movep(1,0)
|
movep(1,0)
|
||||||
|
elseif k=="H" and p.x>3 then
|
||||||
|
movep(-3,0)
|
||||||
|
elseif k=="J" and p.y<MSIZE_Y-3 then
|
||||||
|
movep(0,3)
|
||||||
|
elseif k=="K" and p.y>3 then
|
||||||
|
movep(0,-3)
|
||||||
|
elseif k=="L" and p.x<MSIZE_X-3 then
|
||||||
|
movep(3,0)
|
||||||
elseif k=="q" then
|
elseif k=="q" then
|
||||||
exitbool=true
|
exitbool=true
|
||||||
elseif k=="t" then
|
elseif k=="t" then
|
||||||
showmesg("This is a test")
|
mesg_string="This is a test"
|
||||||
elseif k=="g" then
|
elseif k=="c" then
|
||||||
changep()
|
changep()
|
||||||
elseif k=="." then
|
elseif k=="." then
|
||||||
map[p.x][p.y]=p.glyph
|
map[p.x][p.y]=p.glyph
|
||||||
@ -84,18 +97,49 @@ function await_cmd()
|
|||||||
write()
|
write()
|
||||||
elseif k=="?" then
|
elseif k=="?" then
|
||||||
help()
|
help()
|
||||||
|
elseif k=="o" then
|
||||||
|
-- TODO OPTIONS -----
|
||||||
|
elseif k=="s" then
|
||||||
|
changesize()
|
||||||
|
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO make load func TODO
|
-- TODO make load func TODO
|
||||||
|
function loadf(fn)
|
||||||
|
local tbl
|
||||||
|
fp=io.open(fn,"r")
|
||||||
|
ftxt={}
|
||||||
|
i=1
|
||||||
|
for i=1,MSIZE_Y do
|
||||||
|
ftxt[i]=io.read("l")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- XXX This func is garbage XXX
|
||||||
|
-- initialze table
|
||||||
|
for ix=1,MSIZE_X do
|
||||||
|
for iy=1,MSIZE_Y do
|
||||||
|
tbl[ix]={}
|
||||||
|
tbl[ix][iy]=0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Read file
|
||||||
|
for ix=1,MSIZE_X do
|
||||||
|
for iy=1,MSIZE_Y do
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
function help()
|
function help()
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
nc.setfontcolor("BLUE")
|
nc.setfontcolor("BLUE")
|
||||||
printul("graphed commands")
|
printul("graphed commands")
|
||||||
print("g -> change current glyph")
|
print("c -> change current glyph")
|
||||||
print(". -> place current glyph on screen")
|
print(". -> place current glyph on screen")
|
||||||
print("x -> delete glyph under cursor")
|
print("x -> delete glyph under cursor")
|
||||||
-- TODO
|
-- TODO
|
||||||
@ -105,6 +149,20 @@ function help()
|
|||||||
nc.setfontcolor("WHITE")
|
nc.setfontcolor("WHITE")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function changesize()
|
||||||
|
nc.clrscr()
|
||||||
|
print("Enter y size(lines)")
|
||||||
|
yin=io.read("l")
|
||||||
|
print("Enter y size(lines)")
|
||||||
|
xin=io.read("l")
|
||||||
|
|
||||||
|
MSIZE_X=tonumber(xin)
|
||||||
|
MSIZE_Y=tonumber(yin)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function write()
|
function write()
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
print("Enter Filename")
|
print("Enter Filename")
|
||||||
@ -117,9 +175,10 @@ function write()
|
|||||||
end
|
end
|
||||||
fp:write("\n")
|
fp:write("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
fp:close()
|
fp:close()
|
||||||
nc.clrscr()
|
nc.clrscr()
|
||||||
showmesg("wrote to file:'"..fn.."'. Press enter")
|
mesg_string="Wrote to file : "..fn
|
||||||
end
|
end
|
||||||
|
|
||||||
function movep(dx,dy)
|
function movep(dx,dy)
|
||||||
@ -136,5 +195,7 @@ function changep()
|
|||||||
p.glyph=c
|
p.glyph=c
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- -------------------------------------------
|
||||||
|
-- To write a ephemeral message that gets erased after any input (unlike 'press enter') messages then set 'mesg_string' to any value
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
start()
|
start()
|
||||||
|
@ -6,6 +6,12 @@ function printul(s)
|
|||||||
nc.setunderline(false)
|
nc.setunderline(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function printcol(str,col)
|
||||||
|
nc.setfontcolor(col)
|
||||||
|
print(str)
|
||||||
|
nc.setfontcolor("WHITE")
|
||||||
|
end
|
||||||
|
|
||||||
function mkmat()
|
function mkmat()
|
||||||
local mt
|
local mt
|
||||||
mt = {} -- create the matrix
|
mt = {} -- create the matrix
|
||||||
|
Loading…
Reference in New Issue
Block a user