1. Before posting any MODs, please contact us at support@portalarium.com to ensure your MOD is acceptable to the Terms of Service and EULA of the game. Portalarium is not responsible for use of MODs and possible adverse effects on your client or computer, and we may take action on accounts using MODs that are deemed illegal. Whether submitted here or elsewhere in the community, use MODs at your own risk!
    Dismiss Notice

alternate loctracker

Discussion in 'Lua Discussions' started by CatweazleX, Nov 20, 2019.

  1. CatweazleX

    CatweazleX Avatar

    Messages:
    639
    Likes Received:
    757
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    Code:
    function ShroudOnStart()
    
    ui.onInit(function()
    
        loctrack = {
            isMoving = false,
            lastMoved = os.time(),
            isIdle = true,
            loc = player.location(),
            shadow = createLabel((client.screen.width - 380) / 2 + 1, 91, 380, 24),
            label = createLabel(nil, 90, 380, 24),
            timer = setInterval(0.25, function()
    
                local loc = player.location()
    
                loctrack.isMoving = loc.x != loctrack.loc.x or loc.y != loctrack.loc.y or loc.z != loctrack.loc.z
                loctrack.loc = loc
    
                if loctrack.isMoving then loctrack.lastMoved = os.time() end
    
                loctrack.isIdle = os.time() - loctrack.lastMoved > 5
    
                if loctrack.isIdle then
                    setLabelText(loctrack.label, string.format("<size=14><color=lightblue><b>Stillness since: %s in %s</b></color></size>", os.date("%x %X",loctrack.lastMoved), loc.scene))
                    setLabelText(loctrack.shadow, string.format("<size=14><color=black><b>Stillness since: %s in %s</b></color></size>", os.date("%x %X",loctrack.lastMoved), loc.scene))
                else
                    setLabelText(loctrack.label, string.format("<size=14><color=yellow><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loc.scene, loc.x, loc.y, loc.z))
                    setLabelText(loctrack.shadow, string.format("<size=14><color=black><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loc.scene, loc.x, loc.y, loc.z))
                end
    
                setLabelVisible(loctrack.label, loctrack.isMoving or loctrack.isIdle)
                setLabelVisible(loctrack.shadow, isLabelVisible(loctrack.label))
    
            end)
        }
      
        ui.registerKey("RightAlt", "L", function()
            local l = getLabel(loctrack.label)
            local s = getLabel(loctrack.shadow)
            local t = getTimer(loctrack.timer)
          
            t.enabled = not t.enabled
            l.visible = t.enabled
            s.visible = t.enabled
          
            local msg = createLabel(nil, nil, 180, 120)
            if t.enabled then
                setLabelText(msg, "<size=16><color=white>locTracker activated</color></size>")
            else
                setLabelText(msg, "<size=16><color=white>locTracker deactivated</color></size>")
            end
            showLabel(msg)
            setTimeout(3, function() removeLabel(msg) end)
        end)
    
    end)
    
    
    
    end -- ShroudOnStart
    
    
    -- kill hooks
    function ShroudOnConsoleInput() end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
    

    needs libsota.0.3.8

    With RightAlt + L the loctracker can be toggled on or off
     
    Last edited: Nov 22, 2019
    Retlaw, Browncoat Jayson and Rinaldi like this.
  2. Ravalox

    Ravalox Dev At Large Moderator SOTA Developer

    Messages:
    496
    Likes Received:
    1,243
    Trophy Points:
    55
    Gender:
    Male
    Location:
    Austin, TX
    Nice! Makes "fox hunts" much easier!
     
  3. CatweazleX

    CatweazleX Avatar

    Messages:
    639
    Likes Received:
    757
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
  4. Cypher Black

    Cypher Black Avatar

    Messages:
    467
    Likes Received:
    968
    Trophy Points:
    43
    Location:
    Canada
    Hi

    The Font is VERY small and it vanishes as soon as I stop moving, which makes it hard if I want to record my location.

    Can you add a font sizer so players can edit the size of the font to better fit their needs?

    Thanks!

    Cypher Black
     
    Jaesun likes this.
  5. CatweazleX

    CatweazleX Avatar

    Messages:
    639
    Likes Received:
    757
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    Hi,

    Yes. Can add commands for the loctracker -> \loctrack ... that allows some settings.
     
  6. CatweazleX

    CatweazleX Avatar

    Messages:
    639
    Likes Received:
    757
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    Code:
    -- locTracker by Catweazle Waldschrath
    -- requires libsota.0.4.0 and libsota.0.4.util
    
    function ShroudOnStart()
    
    
    
    ui.onInit(function()
    
        loctrack = {
            enabled = true,
            shadow = createLabel((client.screen.width - 400) / 2 + 1, 91, 400, 24),
            label = createLabel(nil, 90, 400, 24),
            timer = setInterval(0.25, function()
                local loc = player.location
                setLabelText(loctrack.label, string.format("<size=14><color=yellow><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loc.scene.name, loc.x, loc.y, loc.z))
                setLabelText(loctrack.shadow, string.format("<size=14><color=black><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loc.scene.name, loc.x, loc.y, loc.z))       
            end),
            visible = function(visible)
                setLabelVisible(loctrack.label, visible)
                setLabelVisible(loctrack.shadow, visible)
            end,
        }
       
        ui.onPlayerChanged(function(what)
            if not loctrack.enabled then return end
           
            local loc = player.location
    
            if what == "moving" then
                loctrack.visible(true)
                resumeTimer(loctrack.timer)
            elseif what == "standing" then
                pauseTimer(loctrack.timer)
                loctrack.visible(false)
            elseif what == "stillness" then
                setLabelText(loctrack.label, string.format("<size=14><color=lightblue><b>Stillness since: %s in %s</b></color></size>", os.date("%x %X",player.lastMoved), loc.scene.name))
                setLabelText(loctrack.shadow, string.format("<size=14><color=black><b>Stillness since: %s in %s</b></color></size>", os.date("%x %X",player.lastMoved), loc.scene.name))
                pauseTimer(loctrack.timer)
                loctrack.visible(true)
            end
        end)
    
        ui.command.add("loctrack", function(state)
            local enable = not loctrack.enabled
            if state then enable = state == "on" end
    
            local msg = createLabel(nil, nil, 275, 24)
            moveLabelBy(msg, 0, -160)
    
            if loctrack.enabled == enable then
                if loctrack.enabled then
                    setLabelText(msg, "<size=18><color=yellow><b>locTracker already activated</b></color></size>")
                else
                    setLabelText(msg, "<size=18><color=yellow><b>locTracker already deactivated</b></color></size>")
                end
            else
                loctrack.enabled = enable
    
                if loctrack.enabled then
                    loctrack.visible(player.isMoving or player.isStill)
                    resumeTimer(loctrack.timer)
                    setLabelText(msg, "<size=18><color=white><b>locTracker was activated</b></color></size>")
                else
                    loctrack.visible(false)
                    pauseTimer(loctrack.timer)
                    setLabelText(msg, "<size=18><color=white><b>locTracker was deactivated</b></color></size>")
                end
            end
            showLabel(msg)
            setTimeout(3, function() removeLabel(msg) end)
        end)
        ui.registerKey("RightAlt", "L", "loctrack")
    
    end)
    
    
    
    end -- ShroudOnStart
    
    
    -- kill hooks
    function ShroudOnConsoleInput() end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
    

    needs libsota.0.4.0 and libsota.util.0.4 both are here
    needs live build 1077

    With RightAlt + L or \loctrack the locTracker can be toggled on or off
    \loctrack on turns locTracker on, and \loctrack off turns the locTracker off
     
    Last edited: Nov 22, 2019
  7. CatweazleX

    CatweazleX Avatar

    Messages:
    639
    Likes Received:
    757
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    Code:
    -- locTracker by Catweazle Waldschrath
    -- libsota.0.4.1 and libsota.0.4.util
    
    function ShroudOnStart()
    
    
    
    ui.onInit(function()
    
        menu = {
            shortcut = {},
            visible = false,
            background = createLabel(nil, nil, 380, 100, "<color=#000000bb>"..string.rep("█", 300).."</color>"),
            menuText = createLabel(nil, nil, 370, 90),
            _clearShortcuts = function()
                for i,s in next, menu.shortcut do
                    ui.shortcut.remove(s)
                    menu.shortcut[i] = nil
                end
            end,
            show = function()
                menu._clearShortcuts()
                setLabelCaption(loctrack.label, "")
                setLabelCaption(menu.menuText, "<b>locTracker</b>\n\nPress RightAlt + S to change font size\nPress RightAlt + M to move\nPress RightAlt + L to close the menu")
                showLabel(menu.background)
                showLabel(menu.menuText)
                menu.visible = true
                menu.shortcut["s"] = ui.shortcut.add("pressed", "RightAlt", "S", function()
                    menu._clearShortcuts()
                    menu.shortcut["s1"] = ui.shortcut.add("watch", "RightAlt", "UpArrow", function(keyState) loctrack.resize(1, keyState) end)
                    menu.shortcut["s2"] = ui.shortcut.add("watch", "RightAlt", "DownArrow", function(keyState) loctrack.resize(-1, keyState) end)
                    menu.shortcut["s3"] = ui.shortcut.add("pressed", "RightAlt", "S", function() menu.show() end)
                    setLabelCaption(menu.menuText, "<b>locTracker : font size</b>\n\nUse RightAlt + Arrow Up/Down to set font size\n\n<- RightAlt + S ")
                   
                end)
                menu.shortcut["m"] = ui.shortcut.add("pressed", "RightAlt", "M", function()
                    menu._clearShortcuts()
                    menu.shortcut["m1"] = ui.shortcut.add("watch", "RightAlt", "UpArrow", function(keyState) loctrack.move(0, -5, keyState) end)
                    menu.shortcut["m2"] = ui.shortcut.add("watch", "RightAlt", "DownArrow", function(keyState) loctrack.move(0, 5, keyState) end)
                    menu.shortcut["m3"] = ui.shortcut.add("watch", "RightAlt", "LeftArrow", function(keyState) loctrack.move(-7, 0, keyState) end)
                    menu.shortcut["m4"] = ui.shortcut.add("watch", "RightAlt", "RightArrow", function(keyState) loctrack.move(7, 0, keyState) end)
                    menu.shortcut["m5"] = ui.shortcut.add("pressed", "RightAlt", "M", function() menu.show() end)
                    setLabelCaption(menu.menuText, "<b>locTracker : move</b>\n\nUse RightAlt + Arrow keys to move\n\n<- RightAlt + M ")
                end)
            end,
            hide = function()
                menu._clearShortcuts()
                hideLabel(menu.menuText)
                hideLabel(menu.background)
                menu.visible = false
            end,
           
        }
    
    
        loctrack = {
            enabled = true,
            fontSize = 14,
            shadow = createLabel((client.screen.width - 420) / 2 + 1, 91, 420, 24),
            label = createLabel(nil, 90, 420, 24),
            timer = setInterval(0.25, function()
                local loc = player.location
                setLabelText(loctrack.label, string.format("<size=%d><color=yellow><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loctrack.fontSize, loc.scene.name, loc.x, loc.y, loc.z))
                setLabelText(loctrack.shadow, string.format("<size=%d><color=black><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loctrack.fontSize, loc.scene.name, loc.x, loc.y, loc.z))       
            end),
            visible = function(visible)
                setLabelVisible(loctrack.label, visible)
                setLabelVisible(loctrack.shadow, visible)
            end,
            resize = function(delta, keyState)
                local loc = player.location
                if keyState == "down" then
                    loctrack.enabled = false
                    loctrack.visible(true)
                elseif keyState == "up" then
                    loctrack.enabled = true
                elseif keyState == "held" or keyState == "pressed" then
                    loctrack.fontSize = loctrack.fontSize + delta
                    if loctrack.fontSize < 12 then loctrack.fontSize = 12 end
                    if loctrack.fontSize*30 > client.screen.width then loctrack.fontSize = client.screen.width / 30 end
                    print(loctrack.fontSize)
                    resizeLabelTo(loctrack.label, loctrack.fontSize*30, loctrack.fontSize*1.5)
                    resizeLabelTo(loctrack.shadow, loctrack.fontSize*30, loctrack.fontSize*1.5)
                    setLabelText(loctrack.label, string.format("<size=%d><color=yellow><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loctrack.fontSize, loc.scene.name, loc.x, loc.y, loc.z))
                    setLabelText(loctrack.shadow, string.format("<size=%d><color=black><b>%s (x: %.2f, y: %.2f, z: %.2f)</b></color></size>", loctrack.fontSize, loc.scene.name, loc.x, loc.y, loc.z))       
                end
            end,
            move = function(deltaX, deltaY, keyState)
                if keyState == "down" then
                    loctrack.enabled = false
                    loctrack.visible(true)
                    moveLabelBy(loctrack.label, deltaX, deltaY)
                    moveLabelBy(loctrack.shadow, deltaX, deltaY)
                elseif keyState == "up" then
                    loctrack.enabled = true
                elseif keyState == "held" then
                    moveLabelBy(loctrack.label, deltaX, deltaY)
                    moveLabelBy(loctrack.shadow, deltaX, deltaY)
                end
            end,
            enable = function(enable)
                local msg = createLabel(nil, nil, 275, 24)
                moveLabelBy(msg, 0, -160)
    
                if loctrack.enabled == enable then
                    if loctrack.enabled then
                        setLabelText(msg, "<size=18><color=yellow><b>locTracker already activated</b></color></size>")
                    else
                        setLabelText(msg, "<size=18><color=yellow><b>locTracker already deactivated</b></color></size>")
                    end
                else
                    loctrack.enabled = enable
    
                    if loctrack.enabled then
                        loctrack.visible(player.isMoving or player.isStill)
                        resumeTimer(loctrack.timer)
                        setLabelText(msg, "<size=18><color=white><b>locTracker was activated</b></color></size>")
                    else
                        loctrack.visible(false)
                        pauseTimer(loctrack.timer)
                        setLabelText(msg, "<size=18><color=white><b>locTracker was deactivated</b></color></size>")
                    end
                end
                showLabel(msg)
                setTimeout(3, function() removeLabel(msg) end)
            end
        }
       
        ui.onPlayerChanged(function(what)
            if not loctrack.enabled then return end
           
            local loc = player.location
    
            if what == "moving" then
                loctrack.visible(true)
                resumeTimer(loctrack.timer)
            elseif what == "standing" then
                setLabelText(loctrack.label, string.format("<size=%d><color=yellow><b>%s (x: %.2f, y: %.2f, z: %.2f) in %s</b></color></size>", loctrack.fontSize, "Standing at", loc.x, loc.y, loc.z, scene.name))
                setLabelText(loctrack.shadow, string.format("<size=%d><color=black><b>%s (x: %.2f, y: %.2f, z: %.2f) in %s</b></color></size>", loctrack.fontSize, "Standing at", loc.x, loc.y, loc.z, scene.name))       
                pauseTimer(loctrack.timer)
                loctrack.visible(true)
            elseif what == "stillness" then
                setLabelText(loctrack.label, string.format("<size=%d><color=lightblue><b>Stillness since: %s in %s</b></color></size>", loctrack.fontSize, os.date("%x %X",player.lastMoved), loc.scene.name))
                setLabelText(loctrack.shadow, string.format("<size=%d><color=black><b>Stillness since: %s in %s</b></color></size>", loctrack.fontSize, os.date("%x %X",player.lastMoved), loc.scene.name))
                pauseTimer(loctrack.timer)
                loctrack.visible(true)
            end
        end)
    
        ui.command.add("loctrack", function(sender, receiver, action, param)
            if sender and sender ~= player.name then return end
    
            if not action then
                if menu.visible then menu.hide() else menu.show() end
            elseif action == "on" or action == "off" then
                loctrack.enable(action == "on")
            elseif action == "size" and tonumber(param) ~= nil then
                loctrack.fontSize = param
                loctrack.resize(0, "held")
            elseif action == "left" and tonumber(param) ~= nil then
                param = param - ui.label[loctrack.label].left
                loctrack.move(param, 0, "held")
            elseif action == "top" and tonumber(param) ~= nil then
                param = param - ui.label[loctrack.label].top
                loctrack.move(0, param, "held")
            end
        end)
        ui.onShortcut("RightAlt", "L", function(keyState)
            if keyState == "up" then
                ui.command.invoke("loctrack")
            elseif keyState == "pressed" then
                menu.hide()
                loctrack.enable(not loctrack.enabled)
            end
        end)
    
    end)
    
    
    
    end -- ShroudOnStart
    
    
    -- kill hooks
    function ShroudOnConsoleInput() end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
    

    needs libsota.0.4.1 and libsota.util.0.4 both are here

    With RightAlt + L or \loctrack the locTracker can be toggled on or off
    If RightAlt + L is held a little longer and then released a menu comes up for resize and move the locTracker
    \loctrack on - switch loctrack on
    \loctrack off - switch loctrack off
    \loctrack left <number> - position the loctracker number pixel from left
    \loctrack top <number> - position the loctracker number pixel from top

    If the shortcut (RightAlt + L) is not working try /lua reload


    (sorry the code is a little spaghetti)
     
    Last edited: Nov 22, 2019
    Jaesun likes this.