-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomlevel.lua
More file actions
56 lines (49 loc) · 1.19 KB
/
Copy pathcustomlevel.lua
File metadata and controls
56 lines (49 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local json = require("json")
function LoadLevel(levelstring)
local ok,result = pcall(json.decode,levelstring)
local leveldat = nil
if ok == false then
print("error decoding level JSON!")
print(result)
return
else
leveldat = result
end
--initialize empty level
--empty the replay buffer so things don't spill between levels
replayBuffer = {}
seentiles = {}
for y=0,25 do
seentiles[y] = {}
for x=0,45 do
seentiles[y][x] = 0
end
end
playerDodge = false
waitturns = 0
controlmode = 0
localenemycount = 0
fObjs={}
eObjs={}
iObjs={}
tilemap = leveldat.tilemap
pObj.pox = leveldat.pObj.pox
pObj.poy = leveldat.pObj.poy
exit = leveldat.exit
secretexit = leveldat.secret
for i,o in ipairs(leveldat.eObjs) do
if (o.above==true and gameskill>=o.skill) or (o.above==false and gameskill<=o.skill) then
makeObj(o.cname,o.pox,o.poy)
localenemycount = localenemycount + 1
end
end
for i,o in ipairs(leveldat.iObjs) do
if (o.above==true and gameskill>=o.skill) or (o.above==false and gameskill<=o.skill) then
if o.item.type~="ammo" then
makeItemObj(o.cname,nil,o.pox,o.poy)
else
makeAmmoObj(o.cname,o.item.amount,o.pox,o.poy)
end
end
end
end