Jump to content

Recommended Posts

I have these line in Modmain.lua

================
W101_FLOAT = 0

if GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) or GLOBAL.IsDLCEnabled(GLOBAL.PORKLAND_DLC) then
     W101_FLOAT=1
end
================
Then In one of several prefabs
================
if W101_FLOAT ==1 then ....
================
However, when the prefab is loaded, the game crashes with the error that the variable is not defined

My knowledge of Lua is limited, and I am sure I am missing something iimportant in the way that Lua works..

Any help would be appreciated.

This would probably be both strict.lua being mean and the scope of the variable.

In modmain:

GLOBAL.global("W101_FLOAT") -- For strict.lua to be happy, declares this as a global

GLOBAL.W101_FLOAT = 1

Prefab:

if _G.W101_FLOAT == 1 then -- _G should be defined here, if not then use GLOBAL.  This forces the global context scope

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...