Removed obsolete gourmand.lua.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1418 c06c8d41-db1a-0410-9941-cceddc491573
N52GRYCIYJDHUEVAZ7V3DA76FN4YQYDOO47E5MRQ3OM54DFSP3YQC -- SPOILER WARNING---- This file contains spoiler information. Do not read or use this file if you-- don't want to be spoiled. Further, the Lua code in this file may use this-- spoily information to take actions on your behalf. If you don't want-- automatic exploitation of spoilers, don't use this.------------------------------------------------------------------------------- gourmand.lua: (requires eat.lua, chnkdata.lua, and safechunk.lua)---- Eats all available chunks on current square and inventory, swapping to an-- identified amulet of the gourmand if necessary, with no prompts. Note that-- it relies on spoiler information to identify chunks it can eat without-- prompting the user.---- This is a Lua macro, so the action will be interrupted by the hp/stat loss,-- or monsters.---- To use this, add these line to your init.txt:-- lua_file = lua/gourmand.lua---- And macro the "eat_gourmand" function to a key.----------------------------------------------------------------------------- Macroablefunction eat_gourmand()local race = you.race()local all = { }for _, it in ipairs(you.floor_items()) do table.insert(all, it) endfor _, it in ipairs(item.inventory()) do table.insert(all, it) endlocal chunks = { }local needgourmand = falselocal oneedible = falsefor _, itym in ipairs(all) doif food.ischunk(itym) thentable.insert(chunks, itym)endendfor _, itym in ipairs(chunks) dolocal rot = food.rotting(itym)local mon = chunkmon(itym)if food.can_eat(itym) and sc_safechunk andsc_safechunk(rot, race, mon) thenoneedible = trueend-- If we can't eat it now, but we could eat it if hungry, a gourmand-- switch would be nice.if not food.can_eat(itym) and food.can_eat(itym, false) thenneedgourmand = trueendif sc_safechunk and not sc_safechunk(rot, race, mon)and sc_safechunk(false, race, mon)thenneedgourmand = trueendendif table.getn(chunks) == 0 thencrawl.mpr("No chunks to eat.")returnendlocal amuremovedif needgourmand and not oneedible thenamuremoved = switch_amulet("gourmand")endfor _, ch in ipairs(chunks) doif food.can_eat(ch) and is_chunk_safe(ch) thenwhile item.quantity(ch) > 0 doif food.eat(ch) thencoroutine.yield(true)elsebreakendendendendif amuremoved thenswitch_amulet(amuremoved)endendfunction chunkmon(chunk)local cname = item.name(chunk)local mon_, _, mon = string.find(cname, "chunk of (.+) flesh")return monendfunction switch_amulet(amu)local towearif type(amu) == "string" thenfor _, it in ipairs(item.inventory()) doif item.class(it, true) == "jewelry"and item.subtype(it) == amuand not item.cursed(it) thentowear = item.slot(it)breakendendif not towear thencrawl.mpr("Can't find suitable amulet: " .. amu)coroutine.yield(false)endelsetowear = amuendlocal curramu = item.equipped_at("amulet")if curramu and item.cursed(curramu) thencrawl.mpr("Can't swap out cursed amulet!")coroutine.yield(false)endlocal wearitem = item.inslot(towear)if curramu thenif not item.remove(curramu) thencoroutine.yield(false)end-- Yield, so that a turn can pass and we can take another action.coroutine.yield(true)endif not item.puton(wearitem) thencoroutine.yield(false)endcoroutine.yield(true)return curramu and item.slot(curramu)endfunction c_interrupt_macro(interrupt_name)return interrupt_name == "hp_loss" or interrupt_name == "stat" orinterrupt_name == "monster" or interrupt_name == "force"end
Your choice of editor can greatly affect your level building. While vi'sreputation may be close to Crawl's when it comes to fiendishness, thereis a style file (levdes.vim in the dat directory) which helps tremendously(it colours the various glyphs on the maps, and it highlights the syntax).Even Windows users can profit from this by using gvim, a freeware vimclone with a graphical user interface which knows shortcuts like Ctrl-Xetc.
If you use vim, the levdes.vim syntax highlighting script (providedin the dat directory) can make level-editing far more pleasant by colouringdifferent features in maps and syntax-highlighting .des-file syntax. vim isavailable for nearly all operating systems, including Windows.