diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-22 12:40:10 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-22 12:40:10 +0000 |
commit | 639bda974405b152b7655657a8a4af441888d74c (patch) | |
tree | de6ee59345533e113cedfa0aecce31df00174246 /crawl-ref/source | |
parent | abb8fd86e78c57461f6729faafec5ea35ccd18a9 (diff) | |
download | crawl-ref-639bda974405b152b7655657a8a4af441888d74c.tar.gz crawl-ref-639bda974405b152b7655657a8a4af441888d74c.zip |
Moved lua/base.lua -> dat/clua/userbase.lua, source it automatically.
Removed references to base.lua from init.txt, and the other lua files.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1623 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/clua.cc | 2 | ||||
-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.lua | 2 | ||||
-rw-r--r-- | crawl-ref/source/lua/runrest.lua | 2 | ||||
-rw-r--r-- | crawl-ref/source/lua/trapwalk.lua | 91 |
5 files changed, 51 insertions, 56 deletions
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 |