MidrealmDM Posted January 20, 2019 Share Posted January 20, 2019 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. Link to comment https://forums.kleientertainment.com/forums/topic/101977-defining-a-variable-in-modmain/ Share on other sites More sharing options...
CarlZalph Posted January 20, 2019 Share Posted January 20, 2019 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 Link to comment https://forums.kleientertainment.com/forums/topic/101977-defining-a-variable-in-modmain/#findComment-1145062 Share on other sites More sharing options...
MidrealmDM Posted January 20, 2019 Author Share Posted January 20, 2019 Thank much... that helped a lot. Link to comment https://forums.kleientertainment.com/forums/topic/101977-defining-a-variable-in-modmain/#findComment-1145210 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now