summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/init.txt1
-rw-r--r--crawl-ref/source/clua.cc2
-rw-r--r--crawl-ref/source/dat/clua/userbase.lua (renamed from crawl-ref/source/lua/base.lua)10
-rw-r--r--crawl-ref/source/lua/gearset.lua2
-rw-r--r--crawl-ref/source/lua/runrest.lua2
-rw-r--r--crawl-ref/source/lua/trapwalk.lua91
6 files changed, 51 insertions, 57 deletions
diff --git a/crawl-ref/init.txt b/crawl-ref/init.txt
index 3bdffe37e3..c1569ffb13 100644
--- a/crawl-ref/init.txt
+++ b/crawl-ref/init.txt
@@ -52,7 +52,6 @@
##### 3- Lua Files #################################################
#
-lua_file = lua/base.lua
lua_file = lua/stash.lua
lua_file = lua/wield.lua
lua_file = lua/kills.lua
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 2f21d7db44..da7c886541 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -588,6 +588,8 @@ void CLua::init_lua()
lua_register(_state, "pcall", clua_guarded_pcall);
lua_register(_state, "loadfile", clua_loadfile);
lua_register(_state, "dofile", clua_dofile);
+
+ execfile("clua/userbase.lua", true);
}
}
diff --git a/crawl-ref/source/lua/base.lua b/crawl-ref/source/dat/clua/userbase.lua
index db7b15afda..669b4d8b84 100644
--- a/crawl-ref/source/lua/base.lua
+++ b/crawl-ref/source/dat/clua/userbase.lua
@@ -1,12 +1,6 @@
---------------------------------------------------------------------------
--- base.lua:
--- Base Lua definitions that other Lua scripts rely on.
--- NOTE: Other Lua scripts may demonstrate buggy behaviour if you do
--- not source this file. If you're using no Lua scripts at all, you
--- needn't source base.lua.
---
--- To use this, add this line to your init.txt:
--- lua_file = lua/base.lua
+-- userbase.lua:
+-- Base Lua definitions that other Lua scripts rely on (auto-loaded).
---------------------------------------------------------------------------
-- Lua global data
diff --git a/crawl-ref/source/lua/gearset.lua b/crawl-ref/source/lua/gearset.lua
index 494ebd65ff..392c7e6f60 100644
--- a/crawl-ref/source/lua/gearset.lua
+++ b/crawl-ref/source/lua/gearset.lua
@@ -1,5 +1,5 @@
------------------------------------------------------------------------
--- gearset.lua: (requires base.lua)
+-- gearset.lua:
-- Allows for quick switching between two sets of equipment.
--
-- IMPORTANT
diff --git a/crawl-ref/source/lua/runrest.lua b/crawl-ref/source/lua/runrest.lua
index 1432223389..25c1ac44eb 100644
--- a/crawl-ref/source/lua/runrest.lua
+++ b/crawl-ref/source/lua/runrest.lua
@@ -1,5 +1,5 @@
---------------------------------------------------------------------------
--- runrest.lua: (requires base.lua)
+-- runrest.lua:
-- Controls shift-running and resting stop conditions.
--
-- To use this, add this line to your init.txt:
diff --git a/crawl-ref/source/lua/trapwalk.lua b/crawl-ref/source/lua/trapwalk.lua
index 511860353c..37ecc99192 100644
--- a/crawl-ref/source/lua/trapwalk.lua
+++ b/crawl-ref/source/lua/trapwalk.lua
@@ -1,46 +1,45 @@
----------------------------------------------------------------------------
--- trapwalk.lua: (requires base.lua)
--- (Thanks to JPEG <erinacea@hotmail.de> for this script.)
---
--- Allows travel to cross traps provided you have sufficient HP to survive the
--- trap.
---
--- To use this, add this line to your init.txt:
--- lua_file = lua/trapwalk.lua
--- and add
--- trapwalk_safe_hp = dart:15, needle:25, spear:50
--- or similar to your init.txt.
---
--- What it does:
---
--- * Normally autotravel automatically avoids all traps
--- * This script allows you to customize at which hp what type of trap is
--- regarded as safe for autotravel
---
--- IMPORTANT: trapwalk options must be defined *after* sourcing trapwalk.lua.
----------------------------------------------------------------------------
-
--- Travel will cross certain traps if you have more than safe_hp hp.
-
-function ch_cross_trap(trap)
-
- if not options.trapwalk_safe_hp then
- return false
- end
-
- local opt = options.trapwalk_safe_hp
-
- local hpstr
- _, _, hpstr = string.find(opt, trap .. "%s*:%s*(%d+)")
-
- if not hpstr then
- return false
- end
-
- local safe_hp = tonumber(hpstr)
- local hp = you.hp()
-
- -- finally compare current hp with safe limit
- return hp >= safe_hp
-
-end
+---------------------------------------------------------------------------
+-- trapwalk.lua:
+-- (Thanks to JPEG <erinacea@hotmail.de> for this script.)
+--
+-- Allows travel to cross traps provided you have sufficient HP to survive the
+-- trap.
+--
+-- To use this, add this line to your init.txt:
+-- lua_file = lua/trapwalk.lua
+-- and add
+-- trapwalk_safe_hp = dart:15, needle:25, spear:50
+-- or similar to your init.txt.
+--
+-- What it does:
+--
+-- * Normally autotravel automatically avoids all traps
+-- * This script allows you to customize at which hp what type of trap is
+-- regarded as safe for autotravel
+--
+-- IMPORTANT: trapwalk options must be defined *after* sourcing trapwalk.lua.
+---------------------------------------------------------------------------
+
+-- Travel will cross certain traps if you have more than safe_hp hp.
+
+function ch_cross_trap(trap)
+
+ if not options.trapwalk_safe_hp then
+ return false
+ end
+
+ local opt = options.trapwalk_safe_hp
+
+ local hpstr
+ _, _, hpstr = string.find(opt, trap .. "%s*:%s*(%d+)")
+
+ if not hpstr then
+ return false
+ end
+
+ local safe_hp = tonumber(hpstr)
+ local hp = you.hp()
+
+ -- finally compare current hp with safe limit
+ return hp >= safe_hp
+end