NinjaWafflesOfDooM Posted May 2, 2021 Share Posted May 2, 2021 Hi, I'm trying to make a server mod and still just playing around but I've hit an issue that I don't quite understand. In modmain.lua I want to do some stuff with radians, but I get an error in the server log: [string "../mods/mymod/modmain.lua"]:186: attempt to perform arithmetic on global 'RADIANS' (a nil value) I don't understand what else I need to do to be able to use that constant in my mod: require("constants") function Test() ... do stuff with RADIANS ... end Test() Link to comment https://forums.kleientertainment.com/forums/topic/129541-need-help-with-my-first-mod/ Share on other sites More sharing options...
CarlZalph Posted May 2, 2021 Share Posted May 2, 2021 2 hours ago, NinjaWafflesOfDooM said: I don't understand what else I need to do to be able to use that constant in my mod: require("constants") function Test() ... do stuff with RADIANS ... end Test() By the time the mod loads constants.lua is already ran, so you don't need to require it. There's a namespace thing that if the thing you're trying to access isn't defined in modutil.lua that you should prepend "GLOBAL." to access it. So your code would look like: local function Test() GLOBAL.print(GLOBAL.RADIANS) end Test() Make sure to keep your functions local for things that are only to be used in your file, speeds up processing time in the LUA runtime. 1 Link to comment https://forums.kleientertainment.com/forums/topic/129541-need-help-with-my-first-mod/#findComment-1455414 Share on other sites More sharing options...
NinjaWafflesOfDooM Posted May 2, 2021 Author Share Posted May 2, 2021 Thanks, that fixed it. Link to comment https://forums.kleientertainment.com/forums/topic/129541-need-help-with-my-first-mod/#findComment-1455475 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