Creating a Menu using TrailKit

Inside main.lua

terrorsoul Beginner General Modding

Open main.lua in an editor of your choice.


At the top we need to tell the code to use trailkit, we can do this by simply putting at the top of your main.lua: 

tm.os.DoFile("trailkit")


Now that you've done that, lets go ahead and define our menu. Standard menus are defined like this:

local windowMenuDefinition = {

    title = "Main Menu (Window)",

    items = {

        {

            type = "button",

            text = "Give Jetpack",

            -- This function runs when the button is clicked

            onClick = function(data)

                local player = TrailKit.Player.getPlayer(data.playerId)

                if player then

                    player:setJetpack(true) -- Turn on jetpack!

                    -- Show a small message

                    TrailKit.UI.createSubtleMessage({ target = data.playerId, header = "Jetpack", message = "Jetpack Enabled!", options = { duration = 2 }})

                end

            end

        },

        {

            type = "button",

            text = "Close",

            action = "back" -- Special action to close/go back

        }

    }

}


Discussion

Please log in to post a comment.