Difference between revisions of "Modding:Tutorial/Constructing a Map/Source"
From DoomRL Wiki
Game Hunter (Talk | contribs) m (slightly different webpage) |
Game Hunter (Talk | contribs) m (fixed for 0995) |
||
Line 8: | Line 8: | ||
webpage = "http://doom.chaosforge.org/wiki/", | webpage = "http://doom.chaosforge.org/wiki/", | ||
version = {0,1,0}, | version = {0,1,0}, | ||
− | drlver = {0,9,9, | + | drlver = {0,9,9,5}, |
type = "single", | type = "single", | ||
description = "This is an example mod, intended to be altered by anyone wanting " .. | description = "This is an example mod, intended to be altered by anyone wanting " .. | ||
Line 90: | Line 90: | ||
Level.name = "Blank Map" | Level.name = "Blank Map" | ||
Level.name_number = 0 | Level.name_number = 0 | ||
− | Level.fill(" | + | Level.fill("wall") |
local translation = { | local translation = { | ||
["."] = "floor", | ["."] = "floor", | ||
− | ["#"] = " | + | ["#"] = "wall", |
[">"] = "stairs", | [">"] = "stairs", | ||
["h"] = {"floor", being = "former"}, --places cell with being on top | ["h"] = {"floor", being = "former"}, --places cell with being on top | ||
Line 124: | Line 124: | ||
]] | ]] | ||
Level.place_tile(translation,map,1,1) | Level.place_tile(translation,map,1,1) | ||
+ | Generator.set_permanence( area.FULL ) | ||
Level.player(39,10) | Level.player(39,10) | ||
end | end | ||
</source> | </source> |
Latest revision as of 00:58, 24 January 2012
--module.lua file module = { id = "blank", name = "A Blank Map", author = "DoomRL Mod Team", webpage = "http://doom.chaosforge.org/wiki/", version = {0,1,0}, drlver = {0,9,9,5}, type = "single", description = "This is an example mod, intended to be altered by anyone wanting " .. "to test things using the DoomRL base set.", difficulty = true, }
--main.lua file core.declare("blank", {} ) function blank.OnEnter() ui.msg("Hello world!") --give the man a shotty player.inv:add("shotgun") --create shotgun shell item with a modified amount of ammo local pack = item.new("shell") pack.ammo = 50 player.inv:add(pack) end --local variables not within a loop are local to the file itself --for global variables (across all files), you want to use core.declare() --always remember to declare things before they are called somewhere else! local countdown = 600 local minute = 0 local exit_check = true function blank.OnTick() --keeps track of game minutes if countdown == 0 then countdown = 600 minute = minute + 1 ui.msg("Number of minutes passed: ".. minute) end countdown = countdown - 1 --warns player if they are on stairs if player:get_position() == coord.new(45,10) and exit_check then ui.msg("Leaving already?") exit_check = false end if player:get_position() ~= coord.new(45,10) and not exit_check then exit_check = true end end local killCount = 0 function blank.OnKill() killCount = killCount + 1 --display messages dependent on kills if killCount == 1 then ui.msg("You have killed 1 enemy.") else ui.msg("You have killed " .. killCount .. " enemies.") end if killCount == 10 then ui.msg("Wow, killing spree!") end end function blank.OnKillAll() --more enemies are added whenever all are defeated Level.summon("former",5) ui.msg("They just keep coming!!") --as a compensation, you are healed to 100% each time player.hp = player.hpmax end function blank.OnExit() ui.msg_enter("Goodbye world!") end --Personally I like to add this at the end, but these hooks can be placed in any order. function blank.run() Level.name = "Blank Map" Level.name_number = 0 Level.fill("wall") local translation = { ["."] = "floor", ["#"] = "wall", [">"] = "stairs", ["h"] = {"floor", being = "former"}, --places cell with being on top ["]"] = {"floor", item = "garmor"}, --places cell with item on top ["k"] = {"floor", being = "former", item = "phase"}, --places cell with both } local map = [[ ############################################################################## #............................................................................# #............................................................................# #............................................................................# #............................................................................# #...................................................h........................# #............................................................................# #......................................................h.....................# #............................................................................# #......................................]....>........h.....k.................# #............................................................................# #......................................................h.....................# #............................................................................# #...................................................h........................# #............................................................................# #............................................................................# #............................................................................# #............................................................................# #............................................................................# ############################################################################## ]] Level.place_tile(translation,map,1,1) Generator.set_permanence( area.FULL ) Level.player(39,10) end