diff --git a/luprex/core/lua/horps.lua b/luprex/core/lua/horps.lua index ad74aa1f..51c09dc7 100644 --- a/luprex/core/lua/horps.lua +++ b/luprex/core/lua/horps.lua @@ -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 diff --git a/luprex/core/lua/login.lua b/luprex/core/lua/login.lua index ed236251..b8d4eb67 100644 --- a/luprex/core/lua/login.lua +++ b/luprex/core/lua/login.lua @@ -7,6 +7,7 @@ end function login.cb_becomeplayer(actor, place, dialog) tangible.setclass(actor, player) + tangible.animate(actor,{action="warp",plane="main",x=0,y=0,z=0}) end function login.cb_p123(actor, place, dialog)