@ -13,7 +13,7 @@
save_state="y"
save_state="y"
date_written="2019-12-26 08:18:35"
date_written="2019-12-26 08:18:35"
requires="4.80"
requires="4.80"
version="1.1 "
version="1.0 "
>
>
</plugin>
</plugin>
@ -53,13 +53,22 @@
sequence="100"
sequence="100"
>
>
</trigger>
</trigger>
<trigger
group="Slots"
match="^Game pays: ([\d,]+) credits"
name="gameCredits"
regexp="y"
script="creditsData"
sequence="100"
>
</trigger>
</triggers>
</triggers>
<!-- Aliases -->
<!-- Aliases -->
<aliases >
<aliases >
<alias
<alias
match="slot(?:s|S)tats"
match="^ slot(?:s|S)tats$ "
enabled="y"
enabled="y"
regexp="y"
regexp="y"
group="Slots"
group="Slots"
@ -67,12 +76,50 @@
sequence="100"
sequence="100"
>
>
</alias>
</alias>
<alias
match="^slot(?:d|D)ata$"
enabled="y"
regexp="y"
group="Slots"
script="showData"
sequence="100"
>
</alias>
<alias
match="^slot(?:r|R)eset$"
enabled="y"
regexp="y"
group="Slots"
script="resetSlots"
sequence="100"
>
</alias>
<alias
match="^slot(?:h|H)elp$"
enabled="y"
regexp="y"
group="Slots"
script="showHelp"
sequence="100"
>
</alias>
</aliases>
</aliases>
<!-- Script -->
<!-- Script -->
<script >
<script >
< ![CDATA[
< ![CDATA[
require 'commas'
require 'commas'
require 'serialize'
require 'tprint'
function resetSlots()
SetVariable("slotTries", 0)
SetVariable("coinsSpent", 0)
SetVariable("slotPay", 0)
creditsTable = {}
SetVariable("creditsTable", serialize.save("creditsTable"))
end
function OnPluginInstall()
function OnPluginInstall()
if not GetVariable("slotTries") then
if not GetVariable("slotTries") then
@ -87,12 +134,19 @@ function OnPluginInstall()
SetVariable("slotPay", 0)
SetVariable("slotPay", 0)
end
end
ColourNote("white", "blue", "Type '", "yellow", "blue", "slotStats", "white", "blue", "' to view stats.")
if not GetVariable("creditsTable") then
creditsTable = {}
else
assert(loadstring(GetVariable("creditsTable"))) ()
end
ColourNote("white", "blue", "Type '", "yellow", "blue", "slotStats", "white", "blue", "' to view stats. Type '", "yellow", "blue", "slotData", "white", "blue", "' to show other data.")
end
end
function slotStart(name, line, args)
function slotStart(name, line, args)
EnableTrigger("noWin")
EnableTrigger("noWin")
EnableTrigger("slotWin")
EnableTrigger("slotWin")
EnableTrigger("gameCredits")
SetVariable("slotTries", tonumber(GetVariable("slotTries")) + 1)
SetVariable("slotTries", tonumber(GetVariable("slotTries")) + 1)
local current, spent = tonumber(GetVariable("coinsSpent")), string.gsub(args[1], ",", "")
local current, spent = tonumber(GetVariable("coinsSpent")), string.gsub(args[1], ",", "")
@ -104,6 +158,7 @@ end
function slotsWin(name, line, args)
function slotsWin(name, line, args)
EnableTrigger("noWin", false)
EnableTrigger("noWin", false)
EnableTrigger("slotWin", false)
EnableTrigger("slotWin", false)
EnableTrigger("gameCredits", false)
local current, pay = tonumber(GetVariable("slotPay")), string.gsub(args[1], ",", "")
local current, pay = tonumber(GetVariable("slotPay")), string.gsub(args[1], ",", "")
local totalPay = current+tonumber(pay)
local totalPay = current+tonumber(pay)
@ -122,13 +177,13 @@ function showStats()
local difference = pay-spent
local difference = pay-spent
print(string.rep("=",80 ))
print(string.rep("=",79 ))
ColourNote("white", "", "You have spent ", "yellow", "", commas(spent), "white", "", " gold coins over ", "cyan", "", commas(tries), "white", "", " spins, winning ", "yellow", "", commas(pay), "white", "", " gold.")
ColourNote("white", "", "You have spent ", "yellow", "", commas(spent), "white", "", " gold coins over ", "cyan", "", commas(tries), "white", "", " spins, winning ", "yellow", "", commas(pay), "white", "", " gold.")
if difference < 0 t h e n
if difference < 0 t h e n
aheadBehind = "behind"
aheadBehind = "behind"
aheadBehindColour = "red"
aheadBehindColour = "red"
difference = difference*-1
difference = 0- difference
elseif difference > 0 then
elseif difference > 0 then
aheadBehind = "ahead of"
aheadBehind = "ahead of"
aheadBehindColour = "green"
aheadBehindColour = "green"
@ -138,9 +193,50 @@ function showStats()
ColourNote("white", "", "You are ", aheadBehindColour, "", aheadBehind, "white", "", " the House by ", "yellow", "", commas(difference), "white", "", " gold.")
ColourNote("white", "", "You are ", aheadBehindColour, "", aheadBehind, "white", "", " the House by ", "yellow", "", commas(difference), "white", "", " gold.")
ColourNote("white", "", "Average winnings: ", "yellow", "", commas(math.floor(pay/tries)), "white", "", " gold.")
ColourNote("white", "", "Average winnings: ", "yellow", "", commas(math.floor(pay/tries)), "white", "", " gold.")
print(string.rep("=", 80))
print(string.rep("=", 79))
end
function creditsData(name, line, args)
if not creditsTable then creditsTable = {} end
local creditsEarned = string.gsub(args[1], ",", "") .. "c"
if not creditsTable[creditsEarned] then
creditsTable[creditsEarned] = 1
else
creditsTable[creditsEarned] = creditsTable[creditsEarned] + 1
end
SetVariable("creditsTable", serialize.save("creditsTable"))
end
end
function showData()
local sortTable = {}
if tonumber(GetVariable("slotTries")) > 0 then
for i,v in pairs(creditsTable) do
table.insert(sortTable, {credits = string.gsub(i, "c", ""), times = v})
end
table.sort(sortTable, function (a, b) return a.times > b.times end)
print(string.rep("=", 79))
for _,v in ipairs(sortTable) do
creditsStr = v.credits .. " credits"
if creditsStr == "0 credits" then
winCredits = tonumber(GetVariable("slotTries")) - v.times
winCredits = string.format("%.1f", 100*(winCredits/tonumber(GetVariable("slotTries")))) .. "%"
end
creditsStr = creditsStr .. string.rep(" ", 15-#creditsStr) .. ": "
ColourNote("white", "", creditsStr, "cyan", "", v.times, "green", "", " (" .. string.format("%.1f", 100*(tonumber(v.times)/tonumber(GetVariable("slotTries")))) .. "%)")
end
print("")
ColourNote("white", "", "Win percentage: ", "green", "", winCredits or "0.0%")
print(string.rep("=", 79))
else
ColourNote("white", "blue", "You have not logged any slots data yet!")
end
end
function showHelp()
print("slotreset: Resets your slot data")
print("slotstats: Displays winnings")
print("slotdata: Displays percentages")
end
]]>
]]>
</script>
</script>