Backpack package

play it here:

package readme:


– Player Backpack README

  1. Features:
  • uses User Inventory Script for database
  • designed for inventory size of 20
  • equip with mouse click down or controller jump
  • hold items with grip using L1 and R1
  1. Dependices
  • Crayta Inventory Package
  • Crayta Prompts Package
  • Crayta AutoSave Package
  1. Install (4 Steps Required)
  • player backpack template
  • currency add to backpackbar (optional)
  • inventoryItemEquipScript added to items
  • inventorySaveDataScript
  1. Install
  • remove InventoryView template from player
  • place template “Player Backpack” on player template
  • optional - rename to “Backpack”
  • adjust setting
    • backpack (Window Name and Max Weapons)
    • backpackBar (Currency and On Held Item)
    • settings have good tooltips
  1. Install - Currency
  • if no currency is added to the array, none will be displayed
  • one or more currencies can be displayed
  • some currencies are displayed else where on some UI interfaces
  1. Install - On Held Item (GunScript Optional)
  • if using crosshairs:
    • Entity = Crosshair (name of crosshair template under player)
    • Script = crosshairScript
    • Event = SetHeldItem
  1. Install - inventoryItemEquipScript (no value = no equipped)
  • items need a script on them with property called ‘slot’
  • slot values: weapons, gauntlets, boots
    • hotbar is populated by weapons (2 is default)
    • boots and gloves are optional (future implementation planned)
  1. Install - Optional - slot property
  • could be added to other item scripts
  • equip and stow package may work well with this
  1. Install - AutoSave - configuration
  • inventeorySaveScript is missing data in OnSave and OnLoad
  • bug report filed - unless fixed do the following:
  • NEW GAMES (optional or use OLD GAMES path)
    • use modified inventorySaveDataScript
    • add modified script to User / AutoSave
    • change Script in OnLoad and OnSave to InventorySaveDataScript
    • keep original OnLoad and OnSave events
  • OLD GAMES
    • copy all the contents of the inventorySaveDataScript
    • paste over all the contents of the inventorySaveScript
    • the save data is somehow tied to the script name
  • bug report link:
    inventorySaveScript does not save/load data table from inventoryScript - #2 by sinjin
  1. Navigation
  • Item Selection
    • Controller - L-stick moves up, down, left, and right
    • WASD moves up, down, left, and right
    • Mouseover support using real mouse
  1. Backpack - Equip
  • equip up to 2 weapons by default
  • click to equip and unequip items
  • (if used) equip gloves or boots on one click
  1. No HUD (option)
  • if backpackBarWidget is not shown,
    it will display over the backpackWidget
    seemlessly intergrated

TODO - Backpack

  • hold, sort, cancel

TODO - Bar

  • use, drop, cancel

– Changelog

2022-01-26 Initial Package Release
2022-01-27 Weapon Equip Toggle added, Unequip Prompts added
2022-01-28 Sort option added to sorty by type and name
2022-01-29 Sort toggle begining/end mod and added soundasset sort/equip

2 Likes

for default equipped items…



inventoryBackpackDefaultEqipScript

local InventoryBackpackDefaultEquipScript = {}

InventoryBackpackDefaultEquipScript.Properties = {

    { name = "equipTemplates", type = "template", container = "array", 
        tooltip = [[
            equip the following templates for defaults
            note: this could overload the player view
        ]], },
}

function InventoryBackpackDefaultEquipScript:Init()

    local currentLoadout = self:GetEntity().inventoryScript.properties.defaultLoadout or self:GetEntity()
    local inventory = self:GetEntity().inventoryScript.inventory
    
    if currentLoadout then

        local equipTemplates = self:ReturnTable(self.properties.equipTemplates)
        for each, template in pairs(equipTemplates) do
    
            for each, item in pairs(inventory) do
                if item.template == template then
                    print("equip template", item.data["equipped"])
                    table.insert(item.data, {equipped = true})
                end
            end
            
        end

    end
    
end

function InventoryBackpackDefaultEquipScript:ReturnTable(arrayName)

    local tempTable = {}
    for i=1, #arrayName do
        table.insert(tempTable, arrayName[i])
    end
    return tempTable

end

return InventoryBackpackDefaultEquipScript

package has been updated with this script. you need to add it to the inventory folder under user and add the templates to equip.

1 Like