changes
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
makeclass('player')
|
||||
|
||||
--
|
||||
-- Data Structure
|
||||
-- Army.Count
|
||||
-- Army.Kind 'r','p','s'
|
||||
--
|
||||
|
||||
function player.interface(actor, place)
|
||||
gui.menu_item("cb_north", "Go North")
|
||||
gui.menu_item("cb_south", "Go South")
|
||||
@@ -40,6 +46,8 @@ function player.cb_emit_army(actor,place,dialog)
|
||||
t={class='army',x=ax,y=ay,z=0,plane=pl,graphic='army'}
|
||||
pprint("building ",t)
|
||||
tangible.build(t)
|
||||
t.kind='r'
|
||||
t.count=5
|
||||
end
|
||||
|
||||
function player.cb_emit_buff(actor,place,dialog)
|
||||
@@ -57,7 +65,7 @@ function seq(a,b,c) return a<=b and b<=c or false end
|
||||
function player.cb_map(actor,place,dialog)
|
||||
local rad=2
|
||||
local scratch={}
|
||||
local lis=tangible.near(actor,rad*2+1,true,false)
|
||||
local lis=tangible.near(actor,rad,true,false)
|
||||
pprint("cb_map ",lis)
|
||||
for _,t in pairs(lis) do
|
||||
local graphic,plane,x,y,z,facing = tangible.animstate(t)
|
||||
@@ -67,19 +75,35 @@ function player.cb_map(actor,place,dialog)
|
||||
local cl=tangible.getclass(t)
|
||||
print("Offset of "..cl.." is "..offset)
|
||||
if not scratch[offset] then scratch[offset]={} end
|
||||
if not scratch[offset].count then scratch[offset].count={} end
|
||||
if not scratch[offset].armies then scratch[offset].armies={} end
|
||||
if cl=='player' then table.insert(scratch[offset].armies,t) end
|
||||
if not scratch[offset].count then scratch[offset].count={}
|
||||
if not scratch[offset].count[cl] then scratch[offset].count[cl]=0 end
|
||||
scratch[offset].count[cl]=scratch[offset].count[cl]+1
|
||||
if t.count then scratch[offset].count[cl]=scratch[offset].count[cl]+t.count end
|
||||
end
|
||||
for dy=0,rad*2+1 do for line=0,2 do
|
||||
for dy=-rad,rad do for line=0,1 do
|
||||
local lbuf=""
|
||||
for dx=0,rad*2+1 do
|
||||
for dx=-rad,rad do
|
||||
if line==0 then lbuf=lbuf.."---"
|
||||
elseif line==1 then lbuf=lbuf.."-x-"
|
||||
elseif line==2 then lbuf=lbuf.."---"
|
||||
end end
|
||||
elseif line==1 then
|
||||
local kc=0
|
||||
local tc=0
|
||||
local kstr=' '
|
||||
for k,c in pairs(scratch[offset].count) do if c>0 then
|
||||
kc=kc+1
|
||||
tc=tc+c
|
||||
if kc>1 then kstr='M' else kstr=k end
|
||||
end end
|
||||
lbuf=lbuf.."-"..kstr..(tc>0 and tc or " ")
|
||||
end end
|
||||
lbuf=lbuf.."-"
|
||||
print(lbuf)
|
||||
end end
|
||||
lbuf=""
|
||||
for dx=-rad,rad do lbuf=lbuf.."---" end
|
||||
lbuf=lbuf.."-"
|
||||
print(lbuf)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user