Project

General

Profile

How do you integrate the layer z script into an existing script?

Kad_Venku
Added 3 months ago

I've installed the scripts in the appropriate folders, but what do I have to do to get it working in game?

Answers (1)

Kad_Venku
Added 3 months ago

You need to do two things:

  1. Add the following import on top of your existing game object script (where the lines with require("PGStateMachine") are):
    local LayerUtility = require("libLayerZ")
  2. Make sure that the script also so imports PGSpawnUnits. If it doesn't add the line require("PGSpawnUnits")
  3. In the first state (usually State_Init), add the following line in the OnEnter update:
    LayerUtility:enterBattlefield(Object)

You should end up with a script looking something like this:

require("PGStateMachine")
require("PGSpawnUnits")
local LayerUtility = require("libLayerZ")

function Definitions()
    ServiceRate = 1
    Define_State("State_Init", State_Init)
end

function State_Init(message)
    if message == OnEnter then
        if Get_Game_Mode() ~= "Space" then
            ScriptExit()
        end
        LayerUtility:enterBattlefield(Object)
    end
end
    (1-1/1)