Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

replaced map helper function with single add function and map of cons…

…tructors/lambdas
  • Loading branch information...
commit 56d15796d681adc22faad4f471982c76e68539a6 1 parent 43157a7
@SimonLarsen authored
View
2  entity.lua
@@ -215,7 +215,7 @@ function RecordPlayer:getActionBox()
end
function RecordPlayer:action()
- addMessage("TODO Skip song")
+ addMessage("% TODO Skip song %")
end
Telephone = { actiontype = 2, solid = true, interactive = true }
View
96 map.lua
@@ -61,66 +61,40 @@ function loadMapFromImage(name)
end
-- Map helper functions
-add = {}
-function add.e(y,ent)
- table.insert(entities[y],ent)
-end
-function add.door(x,y,dir,lock)
- add.e(y,Door.create(x,y,dir,lock))
-end
-
--- Entities
-function add.vent(x,y,dir,id,dest)
- add.e(y,Vent.create(x,y,dir,id,dest))
-end
-function add.telephone(x,y)
- add.e(y,Telephone.create(x,y))
-end
-function add.closet(x,y)
- add.e(y,Closet.create(x,y))
-end
-function add.recordplayer(x,y)
- add.e(y,RecordPlayer.create(x,y))
-end
-
--- Containers
-function add.cabinet(x,y,storage)
- add.e(y,Cabinet.create(x,y,storage))
-end
-function add.locker(x,y,storage)
- add.e(y,Locker.create(x,y,storage))
-end
-function add.fridge(x,y,storage)
- add.e(y,Fridge.create(x,y,storage))
-end
-function add.toilet(x,y,storage)
- add.e(y,Toilet.create(x,y,storage))
-end
-
--- Table decors
-function add.sink(x,y)
- add.e(y,TableDecor.create(x,y,0))
-end
-function add.oven(x,y)
- add.e(y,TableDecor.create(x,y,7))
-end
+local consts = {
+ -- Special entities
+ door = Door.create,
+ closet = Closet.create,
+ recordplayer = RecordPlayer.create,
+ telephone = Telephone.create,
+ vent = Vent.create,
+ -- Containers
+ toilet = Toilet.create,
+ fridge = Fridge.create,
+ cabinet = Cabinet.create,
+ locker = Locker.create,
+ safe = Safe.create,
+ -- Furniture
+ sofa = Sofa.create,
+ bed = Bed.create,
+ -- Decoration
+ painting = Painting.create,
+ shower = Shower.create,
+ entrance = Entrance.create,
+ television = Television.create,
+ plant = Plant.create,
+ watercooler = Watercooler.create,
+ sink = function(x,y) return TableDecor.create(x,y,0) end,
+ typewriter = function(x,y) return TableDecor.create(x,y,1) end,
+ chair = function(x,y) return TableDecor.create(x,y,2) end,
+ desktelephone = function(x,y) return TableDecor.create(x,y,3) end,
+ book = function(x,y) return TableDecor.create(x,y,4) end,
+ desklamp = function(x,y) return TableDecor.create(x,y,5) end,
+ chairfront = function(x,y) return TableDecor.create(x,y,6) end,
+ oven = function(x,y) return TableDecor.create(x,y,7) end,
+}
--- Decoration stuff
-function add.painting(x,y,id)
- add.e(y,Painting.create(x,y,id))
-end
-function add.entrance(x,y)
- add.e(y,Entrance.create(x,y))
-end
-function add.sofa(x,y,dir)
- add.e(y,Sofa.create(x,y,dir))
-end
-function add.television(x,y)
- add.e(y,Television.create(x,y))
-end
-function add.bed(x,y)
- add.e(y,Bed.create(x,y))
-end
-function add.shower(x,y)
- add.e(y,Shower.create(x,y))
+function add(t,x,y,...)
+ local e = consts[t](x,y,...)
+ table.insert(entities[y],e)
end
View
37 maps/enbane.lua
@@ -1,37 +0,0 @@
-p1start = {3, 1}
-p2start = {2, 1}
-
-local add = add
-
-add.entrance(2,1)
-
--- Doors
-add.door(5,5,"left")
-add.door(17,6,"left")
-add.door(36,9,"vert",1)
-add.door(34,13,"right")
-add.door(19,14,"left")
-add.door(34,23,"right")
-add.door(22,27,"right")
-add.door(4,20,"vert")
-
--- Storage roomso
-add.vent(18,8,"down",1,2)
-
--- Cantina
-add.cabinet(20,10,"key1")
-
--- Kitchen
-add.vent(18,10,"up",2,1)
-
-add.fridge(15,10)
-add.fridge(16,10,"msgThese guys sure like sausage","jamal")
-add.fridge(17,10)
-
-add.sink(13,10)
-add.oven(12,10)
-
-add.sink(13,13)
-add.sink(15,13)
-add.sink(13,16)
-add.sink(15,16)
View
BIN  maps/enbane.png
Deleted file not rendered
View
37 maps/home.lua
@@ -2,29 +2,30 @@ p1start = {6, 2}
p2start = {7, 2}
-- special items
-add.entrance(6,1)
-add.telephone(8,1)
+add("entrance",6,1)
+add("telephone",8,1)
-- Doors
-add.door(4,4,"left")
-add.door(9,4,"right")
-add.door(7,6,"vert")
-add.door(10,10,"right")
+add("door",4,4,"left")
+add("door",9,4,"right")
+add("door",7,6,"vert")
+add("door",10,10,"right")
+
-- Furniture
-add.sofa(2,11,"back")
-add.fridge(11,7,"skinblackmetal")
-add.closet(1,1)
-add.bed(2,1)
-add.toilet(14,1,"skinpoo")
-add.shower(13,1)
-add.recordplayer(1,7)
-add.television(3,7)
+add("sofa",2,11,"back")
+add("fridge",11,7,"skinblackmetal")
+add("closet",1,1)
+add("bed",2,1)
+add("toilet",14,1,"skinpoo")
+add("shower",13,1)
+add("recordplayer",1,7)
+add("television",3,7)
-- Table decoration
-add.sink(12,7)
-add.oven(13,7)
+add("sink",12,7)
+add("oven",13,7)
-- Misc. decorations
-add.painting(9,7,5) -- clock
-add.painting(11,1,6) -- bathroom mirror
+add("painting",9,7,5) -- clock
+add("painting",11,1,6) -- bathroom mirror
View
58 maps/level0.lua
@@ -1,58 +0,0 @@
-p1start = {112,40}
-p2start = {96,40}
-
-table.insert(entities[22],Safe.create(17,22))
-
-table.insert(entities[11],Painting.create(2,11,0))
-table.insert(entities[11],Painting.create(4,11,1))
-
-table.insert(entities[11],Cabinet.create(10,11))
-table.insert(entities[22],Locker.create(12,22))
-
-table.insert(entities[1],Vent.create(12,1,0,1,1))
-table.insert(entities[1],Vent.create(14,1,1,0,-1))
-
-table.insert(entities[9], Vent.create(3, 9,2,3,1337))
-table.insert(entities[11],Vent.create(3,11,3,2,0))
-
-table.insert(entities[11],Plant.create(1,11,0))
-table.insert(entities[11],Plant.create(12,11,1))
-
-table.insert(entities[1],TableDecor.create(3,1,0))
-table.insert(entities[1],TableDecor.create(2,1,7))
-
-table.insert(entities[13],TableDecor.create(2,13,1))
-table.insert(entities[14],TableDecor.create(3,14,2))
-table.insert(entities[17],TableDecor.create(3,17,2))
-table.insert(entities[14],TableDecor.create(9,14,2))
-table.insert(entities[17],TableDecor.create(9,17,2))
-table.insert(entities[16],TableDecor.create(4,16,3))
-table.insert(entities[16],TableDecor.create(8,16,4))
-table.insert(entities[16],TableDecor.create(10,16,5))
-
-table.insert(entities[1],Fridge.create(4,1))
-
-table.insert(entities[11],Watercooler.create(22,11))
-
-table.insert(entities[14],TableDecor.create(16,14,2))
-table.insert(entities[14],TableDecor.create(18,14,2))
-table.insert(entities[14],TableDecor.create(20,14,2))
-table.insert(entities[13],TableDecor.create(16,13,6))
-table.insert(entities[13],TableDecor.create(18,13,6))
-table.insert(entities[13],TableDecor.create(20,13,6))
-
--- Robots
-table.insert(robots,Robot.create({{14,2},{14,8},{22,8},{22,2}}))
-table.insert(robots,Robot.create({{22,8},{22,2},{14,2},{14,8}}))
-table.insert(robots,Robot.create({{17,3},{17,6},{19,6},{19,3}}))
-
--- Cameras
-table.insert(cameras,Camera.create(1,8,0))
-table.insert(cameras,Camera.create(1,17,0))
-table.insert(cameras,Camera.create(12,17,2))
-table.insert(cameras,Camera.create(8,1,3))
-table.insert(cameras,Camera.create(9,9,1))
-
--- Sofa
-table.insert(entities[1],Sofa.create(9,1,3))
-table.insert(entities[4],Sofa.create(9,4,1))
View
BIN  maps/level0.png
Deleted file not rendered
View
50 maps/level1.lua
@@ -1,50 +0,0 @@
-p1start = {8, 3}
-p2start = {9, 21}
-
--- Doors
-table.insert(entities[5],Door.create(6,5,"left"))
-table.insert(entities[5],Door.create(11,5,"right",1))
-table.insert(entities[11],Door.create(5,11,"left"))
-table.insert(entities[16],Door.create(11,16,"right"))
-table.insert(entities[29],Door.create(8,29,"vert"))
-table.insert(entities[10],Door.create(16,10,"vert"))
-
-table.insert(entities[1],TableDecor.create(4,1,0))
-table.insert(entities[1],Fridge.create(1,1,"key1"))
-table.insert(entities[1],Painting.create(2,1,1))
-
-table.insert(entities[1],Cabinet.create(14,1,"msgPoop banana monkey jazz"))
-table.insert(entities[1],Cabinet.create(16,1))
-
-table.insert(entities[10],Locker.create(1,10,"msgNothing but dirty socks in there"))
-table.insert(entities[10],Painting.create(4,10,2))
-table.insert(entities[11],Painting.create(15,11,0))
-table.insert(entities[30],Painting.create(5,30,3))
-
-table.insert(entities[11],Plant.create(14,11,0))
-table.insert(entities[11],Watercooler.create(17,11))
-
-table.insert(entities[11],Cabinet.create(12,11))
-table.insert(entities[30],Cabinet.create(2,30))
-
-table.insert(entities[16],TableDecor.create(14,16,2))
-table.insert(entities[19],TableDecor.create(15,19,2))
-
-table.insert(entities[15],TableDecor.create(14,15,1))
-table.insert(entities[18],TableDecor.create(14,18,1))
-
-table.insert(robots,Robot.create({{13,13},{13,20},{17,20},{17,13}}))
-
-table.insert(entities[28],Vent.create(1,28,"down",1,2))
-table.insert(entities[30],Vent.create(1,30,"up",2,1))
-
-table.insert(cameras,Camera.create(6,10,"down"))
-table.insert(cameras,Camera.create(10,15,"left"))
-
-table.insert(cameras,Camera.create(6,30,"down"))
-table.insert(cameras,Camera.create(7,35,"up"))
-
-table.insert(entities[30],Safe.create(16,30,"goalrare Supernintendo game"))
-
-table.insert(entities[21],Vent.create(4,21,"right",4,5))
-table.insert(entities[21],Vent.create(6,21,"left",5,4))
View
BIN  maps/level1.png
Deleted file not rendered
View
BIN  res/font-white-big.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  resources.lua
@@ -25,7 +25,7 @@ function loadImages()
sansFontImage = lg.newImage("res/font-white-big.png")
sansFontImage:setFilter("nearest","nearest")
- font = lg.newImageFont(sansFontImage," 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!-.,$")
+ font = lg.newImageFont(sansFontImage," 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!-.,$%")
serifFontImage = lg.newImage("res/font-serif.png")
serifFontImage:setFilter("nearest","nearest")
Please sign in to comment.
Something went wrong with that request. Please try again.