Search the Community
Showing results for tags 'global'.
-
Method No.1: Placing files in respective folders within your mod doesn't change whatever you have changed in the files when activating the mod in-game! So, lets say I change total_day_time (total amount of segments) from 16 to 24 (and subsequently change day_segs, night_segs and dusk_segs to correspond to this amount) in a copied tuning.lua file, which I place in [my mod]/scripts folder. Why are no changes applied to my hosted server when I host with the said mod enabled? Is there any code I need to apply in modmain.lua or elsewhere so that the tuning.lua from my mod directly replaces tuning.lua while the mod is enabled? And yes, I know, I've heard it multiple times that file-replacement method isn't optimal for modding, but quite frankly, that's quite fine for the kind of mod that I'm making here. Although, not replacing files via modding and getting it done with a different method is preferable. Method No.2: So, aparently this mod was able to achieve the unachievable; changing local variables (or SOMETHING, somehow) to global. And it flipping works! From my understanding, this is what it in modmain to do so (this isn't the exact code of course, I just took the bits that were relevant): seg_dtime = GetModConfigData("dspeed") * 30 / 8 --Timer segment local total_day_time = seg_dtime * 16 local day_segs = 10 local dusk_segs = 4 local night_segs = 2 GLOBAL.TUNING.SEG_TIME = seg_dtime GLOBAL.TUNING.TOTAL_DAY_TIME = total_day_time GLOBAL.TUNING.DAY_SEGS_DEFAULT = day_segs GLOBAL.TUNING.DUSK_SEGS_DEFAULT = dusk_segs GLOBAL.TUNING.NIGHT_SEGS_DEFAULT = night_segs However, when I put the same code, with just the seg_dtime change to seg_time (and declaring seg_time to what I want, i.e. 60) like this: local seg_time = 60--30 local total_day_time = seg_time*24--16 local day_segs = 12--10 local dusk_segs = 6--4 local night_segs = 6--2 GLOBAL.TUNING.SEG_TIME = seg_time GLOBAL.TUNING.TOTAL_DAY_TIME = total_day_time GLOBAL.TUNING.DAY_SEGS_DEFAULT = day_segs GLOBAL.TUNING.DUSK_SEGS_DEFAULT = dusk_segs GLOBAL.TUNING.NIGHT_SEGS_DEFAULT = night_segs NOTHING changes within the game when I enable my mod. Why? And as a result, how do I achieve this result? I believe there was another mod that changed day time. However, strangely, segment time has not been touched by any mods and I really wonder why, considering segment time, just like total day time (amount of segments) are both local variables declared in tuning.lua.
- 9 replies
-
- day time
- day segments
-
(and 5 more)
Tagged with:
-
[00:00:46]: [string "../mods/workshop-381565292/scripts/prefabs/..."]:42: variable 'GLOBAL' is not declared LUA ERROR stack traceback: =[C]:-1 in (global) error © <-1--1> =-=-=- I've made several changes and still can't get it to work. if GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) or GLOBAL.TheSim:GetGameID()=="DST" then inst.components.edible.temperaturedelta = TUNING.COLD_FOOD_BONUS_TEMP else end
-
I always use _G = GLOBALBecause GLOBAL._G == GLOBAL i.e. _G == _G._G So _G always defined and works fine irrespective of, whether the GLOBAL variable is defined. My question is about "local" statement. Is there difference for optimization between _G = GLOBALand local _G = GLOBALI noticed that I can get variables of local "global space" of other mods by using local env = _G.ModManager:GetMod("modname").envBut there are only "globals", not "locals". E.g. I can use env.x if and only if there is global definition (x=5), and I can't use env.x if there is only local definition (local x=5). So there is some difference. But is there difference for optimization? I read some lua optimization tips. They said that local variables are very fast. But I'm not sure about variable in local global space (environment of the mod). It seems that they are in the same scope. Only difference that locals are invisible for accessing from outside. That's it. So is there any real difference for optimization? Does anybody know?