Skeletons to start with mods

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

Thread Status:
Not open for further replies.
  1. CatweazleX

    CatweazleX Avatar

    Messages:
    643
    Likes Received:
    760
    Trophy Points:
    93
    Location:
    Veritas Sanctuary
    Currently one has to implement all ShroudOn.. functions to not break other people scripts. Players tent to have more then one lua-script in their folder (each mod they like) and that will stay this way.

    ShroudOnStart is called when all scripts are loaded. It is the best to use this as the entry point.

    Here the skeletons:
    Code:
    
    local initialized = false
    
    -- called when all scripts are loaded
    function ShroudOnStart()
    
         -- do your init stuff that does not need the Shroud Api
    end
    
    -- called on every frame
    function ShroudOnUpdate()
    
          if not initialized then
                     -- Shroud Api should be ready at this point. (except globals)
    
                     -- init your stuff that need the Shroud Api
                     initialized = true
          end
    
          -- do processing here
    end
    
    -- called on every line of text that reaches your chatwindow
    function ShroudOnConsoleInput(channel, sender, message)
    
         -- capture console input. If not needed leave empty
    end
    
    -- this is a time critical function, so  Do only drawing here!
    function ShroudOnGUI()
    
         -- ShroudGUILabel(left, top, width, height, caption)
    end
    

    Code:
    -- Shroud Api and libsota are initialized
    function main()
    
        -- your code starts here
    
        -- id = createLabel(left, top, with, height, caption)
        -- id = setInterval(interval, on_update)
        -- showLabel(id)
    end
    
    -- function on_update()
    -- processing here
    -- end
    
    -- local function on_console_input(channel, sender, receiver, message)
    --   -- captures console input
    -- end
    
    
    
    --- call main in your script when all scripts are loaded and Shroud Api ready
    function ShroudOnStart()
    
        ui.onInit(main)
    
    -- map ui events to procedure. uncomment when needed
    -- ui.onConsoleInput(on_console_input)
    -- ui.onConsoleCommand(procdeure)
    -- ui.onSceneChanged(procdeure)
    -- ui.onPlayerChanged(procdeure)
    -- ui.onPlayerMoveStart(procdeure)
    -- ui.onPlayerMoveStop(procdeure)
    -- ui.onPlayerIsStill(procdeure)
    -- ui.onPlayerDamage(procdeure)
    
    
    end
    
    
    -- implement the remaining ShroudOn... functions
    
    function ShroudOnConsoleInput() end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
    Code:
    -- all scripts are loaded
    function ShroudOnStart()
    
    ui.onInit(function()
    -- your init function
    
    -- id = createLabel(left, top, width, height, caption)
    -- id = setInterval(interval, function() end)
    -- showLabel(id)
    
    end)
    
    -- other event handler. uncomment when needed
    -- ui.onConsoleInput(function(channel, sender, receiver, message)
    --   -- captures console input
    -- end)
    -- ui.onConsoleCommand(function(source, command, tail) end)
    -- ui.onSceneChanged(function() end)
    -- ui.onPlayerChanged(function(what, health, focus) end)
    -- ui.onPlayerMoveStart(function() end)
    -- ui.onPlayerMoveStop(function() end)
    -- ui.onPlayerIsStill(function() end)
    -- ui.onPlayerDamage(function(health, focus) end)
    
    
    end -- end ShroudOnStart
    
    -- implement the remaining ShroudOn... functions
    function ShroudOnConsoleInput() end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
     
Thread Status:
Not open for further replies.