changes
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
NilIsZero={
|
makeclass('NilIsZero') -- This is intended to be used as a metatable
|
||||||
__index=function(t,k)
|
|
||||||
|
function NilIsZero.__index(t,k)
|
||||||
return 0
|
return 0
|
||||||
end,
|
end
|
||||||
__newindex=function(t,k,v)
|
|
||||||
|
function NilIsZero.__newindex(t,k,v)
|
||||||
if v~=nil and v~=0 then rawset(t,k,v) end
|
if v~=nil and v~=0 then rawset(t,k,v) end
|
||||||
end }
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -71,20 +71,12 @@ function shuffle(t)
|
|||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
NilIsZero={
|
|
||||||
__index=function(t,k)
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
__newindex=function(t,k,v)
|
|
||||||
if v~=nil and v~=0 then rawset(t,k,v) end
|
|
||||||
end }
|
|
||||||
|
|
||||||
function MakeMap()
|
function MakeMap()
|
||||||
local rad=6
|
local rad=6
|
||||||
for x=-rad,rad do for y=-rad,rad do if math.random(1,5)==1 then
|
for x=-rad,rad do for y=-rad,rad do if math.random(1,5)==1 then
|
||||||
t={class='army',x=x,y=y,z=0,plane='main',graphic='army'}
|
t={class='army',x=x,y=y,z=0,plane='main',graphic='army'}
|
||||||
print("Building an army:")
|
print("Building an army:")
|
||||||
pprint(t)
|
-- pprint(t)
|
||||||
local nt=tangible.build(t)
|
local nt=tangible.build(t)
|
||||||
nt.Count={}
|
nt.Count={}
|
||||||
setmetatable(nt.Count,NilIsZero)
|
setmetatable(nt.Count,NilIsZero)
|
||||||
@@ -93,7 +85,7 @@ function MakeMap()
|
|||||||
nt.Count[type]=nt.Count[type]+math.random(1,3)
|
nt.Count[type]=nt.Count[type]+math.random(1,3)
|
||||||
end end
|
end end
|
||||||
print("Here's what was built:")
|
print("Here's what was built:")
|
||||||
pprint(nt)
|
-- pprint(nt)
|
||||||
end end end
|
end end end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -241,7 +233,7 @@ function player.cb_map(actor,place,dialog)
|
|||||||
end end
|
end end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pprint(scratch)
|
-- pprint(scratch)
|
||||||
for dy=-rad,rad do for line=0,1 do
|
for dy=-rad,rad do for line=0,1 do
|
||||||
local lbuf=""
|
local lbuf=""
|
||||||
for dx=-rad,rad do
|
for dx=-rad,rad do
|
||||||
@@ -258,11 +250,11 @@ function player.cb_map(actor,place,dialog)
|
|||||||
for dx=-rad,rad do lbuf=lbuf.."----" end
|
for dx=-rad,rad do lbuf=lbuf.."----" end
|
||||||
lbuf=lbuf.."-"
|
lbuf=lbuf.."-"
|
||||||
print(lbuf)
|
print(lbuf)
|
||||||
print("In Player "..tangible.id(actor)..":")
|
-- print("In Player "..tangible.id(actor)..":")
|
||||||
for k,v in pairs(actor.Count) do print(" "..k.." "..v) end
|
for k,v in pairs(actor.Count) do print(" "..k.." "..v) end
|
||||||
local lis=tangible.near(actor,0,true,true)
|
local lis=tangible.near(actor,0,true,true)
|
||||||
for k,v in pairs(lis) do
|
for k,v in pairs(lis) do
|
||||||
print("In Army "..tangible.id(v)..":")
|
-- print("In Army "..tangible.id(v)..":")
|
||||||
for k2,v2 in pairs(v.Count) do print(" "..k2.." "..v2) end
|
for k2,v2 in pairs(v.Count) do print(" "..k2.." "..v2) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ function login.interface(actor, place)
|
|||||||
|
|
||||||
function login.cb_becomeplayer(actor, place, dialog)
|
function login.cb_becomeplayer(actor, place, dialog)
|
||||||
actor.kind='P'
|
actor.kind='P'
|
||||||
actor.Count={}
|
actor.Count={} setmetatable(actor.Count,NilIsZero)
|
||||||
setmetatable(actor.Count,NilIsZero)
|
|
||||||
tangible.setclass(actor, player)
|
tangible.setclass(actor, player)
|
||||||
tangible.animate(actor,{action="warp",plane="main",x=0,y=0,z=0})
|
tangible.animate(actor,{action="warp",plane="main",x=0,y=0,z=0})
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user