resources/scripts/Global.lua
-- This file should only be used for globally useful constants and functions.
-- Please put new events, actions, items, etc. in their respective 'main' Lua files.

function split(input, separator)
    if separator == nil then
        separator = '%s'
    end

    local t = {}
    for str in string.gmatch(input, '([^'..separator..']+)') do
        table.insert(t, str)
    end

    return t
end

function getTableSize(tbl)
    local count = 0

    for _, _ in pairs(tbl) do
        count = count + 1
    end

    return count
end

function printf(player, fmt_str, ...)
    -- Sender would be defined elsewhere, if at all
    if command_sender == nil then
        command_sender = ""
    end

    if ... ~= nil then
        player:send_message(command_sender..fmt_str:format(...))
    else
        player:send_message(command_sender..fmt_str)
    end
end

-- Constants
GM_RANK_MAX = 255 -- Doesn't exist, used for purposes of testing permissions in scripts

BED_EVENT_HANDLER = 720916
BED_CUTSCENE_FLAGS = 4165480179 -- TODO: remove this hardcode
BED_SCENE_WAKEUP_ANIM = 00100
ZONE_INTENDED_USE_INN = 2
ZONE_INTENDED_USE_OPENING_AREA = 6
