Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ralt_coin = {}
- local playerDets = Inspect.Unit.Detail("player")
- local playerId = playerDets.id
- local character = playerDets.name
- local function format_total(total)
- local string = tostring(total)
- local len = string.len(string)
- if len <= 2 then
- -- 2 digits ie silver only
- total = total .. "s"
- elseif len <= 4 then
- -- 4 digits ie gold
- local silver = string.sub(total, (len-1), len)
- local gold = string.sub(total, 1, (len-2))
- total = gold .. "g " .. silver .. "s "
- elseif len > 4 then
- -- 6 digits
- local silver = string.sub(total, (len-1), len)
- local gold = string.sub(total, (len-3), (len-2))
- local plat = string.sub(total, 1, (len-4))
- total = plat .. "p " .. gold .. "g " .. silver .. "s "
- end
- return total
- end
- local function get_player_coin()
- return Inspect.Currency.Detail("coin").stack
- end
- local function print_total()
- local total = 0
- local count = 0
- for k,v in pairs(ralt_coin) do
- total = total + v
- count = count + 1
- end
- total = format_total(total)
- print(total .. " (" .. count .. " characters)")
- end
- local function unit_available(unitId)
- if unitId ~= playerId then return end
- -- set variable to coin value
- ralt_coin[character] = get_player_coin()
- end
- local function set_coin()
- ralt_coin[character] = get_player_coin()
- end
- local function print_coin()
- print(get_player_coin())
- end
- -- debug command, check value of ralt_coin
- table.insert(Command.Slash.Register("rcoin"), {print_coin, "rAltInfo", "get current characters coin"})
- table.insert(Command.Slash.Register("rtotal"), {print_total, "rAltInfo", "print total coin"})
- -- insert get and set events
- table.insert(Event.Unit.Availability.Full, {unit_available, "rAltInfo", "set characters coin"})
- table.insert(Event.Currency, {set_coin, "rAltInfo", "set characters coin"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement