Hi guys,
here I present some original content from me for the first time. Although it is just little extension of @Rukasu script.
I written this script in order to have possibility to shutdown bot remotely, but you can do other changes as well with this.
Commands possible:
info
profit
user
Info and profit commands were written by@Rukasu, they print some info about bot.
User gives us possibility to get values of user options (like getuseroption() inside bot), but also gives us possibility to change these values.
Here is some console print out from setting bot to go to depot. If you want to use the persistent same like me below persistent I will leave cavebot action script and useroptions checkbox.
I left an option to force type of usersetting for some troubleshooting.Code:22:39 rwqe [11]: user logoutAtDeposit 22:39 Kharsek [1008]: logoutAtDeposit = false. It is boolean. 22:39 rwqe [11]: user logoutAtDeposit true 22:39 Kharsek [1008]: Set logoutAtDeposit from false to true. 22:40 rwqe [11]: user "Capacity to leave cave?" 22:41 Kharsek [1008]: Capacity to leave cave? = 0. It is string. 22:41 rwqe [11]: user "Capacity to leave cave?" 99999 22:41 Kharsek [1008]: Set Capacity to leave cave? from 0 to 99999.
You can use it like that:
user "usersetting" type value
Type can be: string, number or boolean.
Tell me guys what you think about this.
rwqe
Remote useroptions
init start
-- Remote userseroptions editer and remote info
-- Originally written by [MENTION=11210]Rukasu[/MENTION], edited by rwqe.
-- I deleted some useless - in my opinion - variables and functions,
-- Added what I always wanted to have - remote setting editor.
-- Creation 5/09/2016
-- USAGE:
-- Add to safelist list of remote char. Commands info and profit will print out some useful info about your character. It was originally written by Rukasu.
-- To get user setting simply PM your char with:
-- user "usersettingname"
-- To set user setting write:
-- user "usersettingname" "value"
-- You don't have to use quotations marks if settings and values do not contain of spaces. Although it is recommended.
-- Visit tibiawindbot.com forums for more info.
local safelist = { "Character Name 1", "Character Name 2", "Character Name 3..." } -- Insert as many names as you want.
local commands = { "info", "profit", "user"} -- change to any word you want or just leave as it is.
local safeTalk = false -- talk only while monsters are away
local safeEdit = false -- can edit only usersettings listed below -- if false can edit any
local safeVariables = {"logoutAtDeposit", "Capacity to leave cave?"} --usersetting you can edit remotely if safeEdit is set true. (you can read all variables not only from this list)
------------------------------------------------------------------
-- DON'T TOUCH ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING --
------------------------------------------------------------------
local info = {
function() return "Balance: " .. num($balance) end,
function() return "Stamina: ".. time($stamina) end,
function() return "Played time: ".. time(math.floor($charactertime / 1000)) end,
function() return "Exp/h: ".. num($exphour) end,
function() return "Time to next level: " .. time(timetolevel()) end
} -- Thanks Leonardo
local drop_profit, supply_waste = 0, 0
local old_type = getsetting('Settings/TypeWaitTime')
local old_press = getsetting('Settings/PressWaitTime')
--some useful functions
function table.contains(table, element)
for _, value in pairs(table) do
if value == element then
return true
end
end
return false
end
function string.split(text)
local ret = {}
local e = 0
while true do
local b = e+1
b = text:find("%S",b)
if b==nil then break end
if text:sub(b,b)=="'" then
e = text:find("'",b+1)
b = b+1
elseif text:sub(b,b)=='"' then
e = text:find('"',b+1)
b = b+1
else
e = text:find("%s",b+1)
end
if e==nil then e=#text+1 end
table.insert(ret, (""..text:sub(b,e-1)..""))
end
return ret
end
function string.toBoolean(str)
if str == "true" then
return true
end
if str == "false" then
return false
end
return nil
end
function parser(typ, str)
if table.contains({'str', 'string', 'text', 's', 't'}, typ:lower()) then
return str
end
if table.contains({'num', 'number', 'int', 'integer', 'double', 'n', 'i'}, typ:lower()) then
return tonumber(str)
end
if table.contains({'bool', 'boolean', 'b'}, typ:lower()) then
return string.toBoolean(str)
end
return nil
end
init end
auto(100)
foreach newmessage m do
if m.type == MSG_PVT then
-- set type/press wait time --
setsetting('Settings/TypeWaitTime', '10 to 20 ms')
setsetting('Settings/PressWaitTime', '10 to 20 ms')
if table.contains(safelist, m.sender) then
if maround(7) > 0 and safeTalk then
say("Local Chat", string.format("@%s@ maround: %i", m.sender, maround(7)))
break
end
if m.content:lower() == commands[1]:lower() then
for c = 1, #info do
say("Local Chat", string.format("@%s@ %s", m.sender, info[c]()))
wait(2000,2300)
end
break
end
if m.content:lower() == commands[2]:lower() then
drop_profit = 0
supply_waste = 0
foreach lootingitem drops do
drop_profit = drops.sellprice * drops.amountlooted + drop_profit
end
foreach supplyitem supply do
supply_waste = supply.buyprice * supply.amountused + supply_waste
end
say("Local Chat", string.format("@%s@ %s: %s gps", m.sender, "Total profit", num(drop_profit - supply_waste)))
break
end
-- below some of rwqe work,
local messageArray = string.split(m.content)
if messageArray[1] == commands[3] then
if table.getn(messageArray) == 2 then
local optionValue = getuseroption(messageArray[2])
say("Local Chat", string.format("@%s@ %s = %s. It is %s.", m.sender, messageArray[2], optionValue, type(optionValue)))
break
end
if table.getn(messageArray) == 3 and (safeEdit == false or table.contains(safeEdit, messageArray[2])) then
local optionValue = getuseroption(messageArray[2])
local newOption = parser(type(optionValue), messageArray[3])
setuseroption(messageArray[2], newOption)
say("Local Chat", string.format("@%s@ Set %s from %s to %s.", m.sender, messageArray[2], optionValue, newOption))
break
end
if table.getn(messageArray) == 4 and (safeEdit == false or table.contains(safeEdit, messageArray[2])) then
local optionValue = getuseroption(messageArray[2])
local newOption = parser(messageArray[3], messageArray[4])
setuseroption(messageArray[2], newOption)
say("Local Chat", string.format("@%s@ Set %s from %s to %s.", m.sender, messageArray[2], optionValue, newOption))
break
end
end
end
setsetting('Settings/PressWaitTime', old_press)
setsetting('Settings/TypeWaitTime', old_type)
end
end
User options checkbox (I leave this here for newbies)
Cavebot action script (leave it together with deposit action or somewhere where bot is inside pz)Code:{ "type" : "group", "name" : "Logout when deposit", "children" : [ { "type" : "checkbox", "name" : "logoutAtDeposit", "description" : "Check this box if you want to logout when bot will hit depo.", "text" : "Is this your last round?", "value" : false } ] }
--Last Round Logout cavebot-action script by rwqe
local logout = getuseroption("logoutAtDeposit")
if logout and $battlesigned then
logout()
end