Version 2.0031

1) Fixed "dinv regen" bug that prevented you from sleeping on a piece of furniture
master
Durel 7 years ago
parent 7f0c9608bf
commit 966e980d19

@ -1,6 +1,13 @@
dbot.changelog = {} dbot.changelog = {}
dbot.changelog[2.0031] =
{
{ change = drlDbotChangeLogTypeFix,
desc = [[Fixed @Cregen@W mode bug that prevented you from sleeping on a piece of furniture]]
}
}
dbot.changelog[2.0030] = dbot.changelog[2.0030] =
{ {
{ change = drlDbotChangeLogTypeNew, { change = drlDbotChangeLogTypeNew,

@ -89,7 +89,7 @@ dbot.version : Module to track version and changelog information and update the
save_state="y" save_state="y"
date_written="2017-08-12 08:45:15" date_written="2017-08-12 08:45:15"
requires="4.98" requires="4.98"
version="2.0030" version="2.0031"
> >
<description trim="y"> <description trim="y">
<![CDATA[ <![CDATA[
@ -611,8 +611,8 @@ Feature Wishlist
</alias> </alias>
<alias <alias
script="inv.regen.onSleep" script="inv.cli.regen.fn2"
match="^[ ]*(sl|sle|slee|sleep)[ ]*" match="^[ ]*(sleep|slee|sle|sl)([ ]+[^ ]+)?[ ]*"
enabled="y" enabled="y"
regexp="y" regexp="y"
send_to="12" send_to="12"
@ -3649,6 +3649,16 @@ function inv.cli.regen.fn(name, line, wildcards)
end -- inv.cli.regen.fn end -- inv.cli.regen.fn
function inv.cli.regen.fn2(name, line, wildcards)
local sleepMode = wildcards[1] or ""
local sleepLoc = wildcards[2] or ""
dbot.debug("sleepLoc is \"" .. sleepLoc .. "\"")
return inv.regen.onSleep(sleepLoc)
end -- inv.cli.regen.fn2
function inv.cli.regen.usage() function inv.cli.regen.usage()
dbot.print("@W " .. pluginNameCmd .. " regen @G[on | off]@w") dbot.print("@W " .. pluginNameCmd .. " regen @G[on | off]@w")
end -- inv.cli.regen.usage end -- inv.cli.regen.usage
@ -17656,7 +17666,7 @@ end -- inv.pass.use
-- --
-- dinv regen [on | off] -- dinv regen [on | off]
-- --
-- inv.regen.onSleep -- inv.regen.onSleep(sleepLoc)
-- inv.regen.onSleepCR -- inv.regen.onSleepCR
-- --
-- inv.regen.onWake -- inv.regen.onWake
@ -17671,33 +17681,55 @@ inv.regen = {}
inv.regen.wearableLoc = "lfinger" inv.regen.wearableLoc = "lfinger"
function inv.regen.onSleep() inv.regen.pkg = nil
function inv.regen.onSleep(sleepLoc)
local retval = DRL_RET_SUCCESS
if (inv.config.table.isRegenEnabled) then if (inv.config.table.isRegenEnabled) then
if (inv.regen.pkg ~= nil) then
dbot.info("Skipping regen sleep request: another request is in progress")
retval = DRL_RET_BUSY
else
inv.regen.pkg = {}
inv.regen.pkg.sleepLoc = sleepLoc
wait.make(inv.regen.onSleepCR) wait.make(inv.regen.onSleepCR)
end -- if
else else
check (Send("sleep")) check (Send("sleep " .. (sleepLoc or "")))
end -- if end -- if
return DRL_RET_SUCCESS return retval
end -- inv.regen.onSleep end -- inv.regen.onSleep
function inv.regen.onSleepCR() function inv.regen.onSleepCR()
if (inv.regen.pkg == nil) then
dbot.error("inv.regen.onSleepCR: regen package is nil!?!")
return DRL_RET_INTERNAL_ERROR
end -- if
local sleepCmd = "sleep " .. inv.regen.pkg.sleepLoc
-- First look if the user has at least one item providing the regeneration effect. Get an ID array -- First look if the user has at least one item providing the regeneration effect. Get an ID array
-- for all regen items (currently just regen rings have this effect.) -- for all regen items (currently just regen rings have this effect.)
local regenIdArray, retval = inv.items.searchCR("affectmods regeneration") local regenIdArray, retval = inv.items.searchCR("affectmods regeneration")
if (retval ~= DRL_RET_SUCCESS) then if (retval ~= DRL_RET_SUCCESS) then
dbot.warn("inv.regen.onSleep: Failed to find items with regeneration effect: " .. dbot.warn("inv.regen.onSleep: Failed to find items with regeneration effect: " ..
dbot.retval.getString(retval)) dbot.retval.getString(retval))
check (Send("sleep")) check (Send(sleepCmd))
inv.regen.pkg = nil
return retval return retval
end -- if end -- if
-- If the user doesn't have a regen ring, we are done. Go to sleep as normal and return. -- If the user doesn't have a regen ring, we are done. Go to sleep as normal and return.
if (#regenIdArray == 0) then if (#regenIdArray == 0) then
dbot.info("Skipping regen auto-wear when sleeping: no items with regeneration effect found") dbot.info("Skipping regen auto-wear when sleeping: no items with regeneration effect found")
check (Send("sleep")) check (Send(sleepCmd))
inv.regen.pkg = nil
return DRL_RET_MISSING_ENTRY return DRL_RET_MISSING_ENTRY
end -- if end -- if
@ -17706,7 +17738,8 @@ function inv.regen.onSleepCR()
for _, objId in ipairs(regenIdArray) do for _, objId in ipairs(regenIdArray) do
if inv.items.isWorn(objId) then if inv.items.isWorn(objId) then
dbot.debug("Skipping regen auto-wear when sleeping: You are already wearing a regen item") dbot.debug("Skipping regen auto-wear when sleeping: You are already wearing a regen item")
check (Send("sleep")) check (Send(sleepCmd))
inv.regen.pkg = nil
return DRL_RET_SUCCESS return DRL_RET_SUCCESS
end -- if end -- if
end -- if end -- if
@ -17770,8 +17803,9 @@ function inv.regen.onSleepCR()
-- Don't forget to actually go to sleep now...We use Send() instead of one of the execute functions -- Don't forget to actually go to sleep now...We use Send() instead of one of the execute functions
-- because we don't want our alias to catch this sleep and translate it into another onSleep() call. -- because we don't want our alias to catch this sleep and translate it into another onSleep() call.
check (Send("sleep")) check (Send(sleepCmd))
inv.regen.pkg = nil
return retval return retval
end -- inv.regen.onSleepCR end -- inv.regen.onSleepCR

Loading…
Cancel
Save