Tech level and limiter scripts to JS
- Berserk Cyborg
- Code contributor
- Posts: 938
- Joined: 26 Sep 2016, 19:56
Tech level and limiter scripts to JS
Doing even more WZScript to Javascript conversions. So now I have the tech level enablers and the limiter screen script working. The latter of which seems to need everything globally or it don't work. There was also a bunch of non-existent research in the tech files so I went and removed the unavailable ones
It does have a silent assert when loading a save because it can not find multilim.js. So I pose an interesting question: would it be possible to skip saving and loading a certain script?
Current work.
It does have a silent assert when loading a save because it can not find multilim.js. So I pose an interesting question: would it be possible to skip saving and loading a certain script?
Current work.
Re: Tech level and limiter scripts to JS
Nice work.
There is hackDoNotSave(var name) to not save a particular global variable, but no way to prevent an entire script context from being saved.
Anything you load through the WRF / resource system will get its own script context, which will be saved and require some special handling for load. This is usually a bad idea, I think. Wouldn't it be easier to just include() some of this code from rules.js?
When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
There is hackDoNotSave(var name) to not save a particular global variable, but no way to prevent an entire script context from being saved.
Anything you load through the WRF / resource system will get its own script context, which will be saved and require some special handling for load. This is usually a bad idea, I think. Wouldn't it be easier to just include() some of this code from rules.js?
When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
- Berserk Cyborg
- Code contributor
- Posts: 938
- Joined: 26 Sep 2016, 19:56
Re: Tech level and limiter scripts to JS
Maybe even better: Now I make it so the research is granted within eventGameInit() by adding a JS function called getMultiTechLevel() and moving the research definitions into camTechEnabler.js which is included with rules.js.Per wrote: Anything you load through the WRF / resource system will get its own script context, which will be saved and require some special handling for load. This is usually a bad idea, I think. Wouldn't it be easier to just include() some of this code from rules.js?
That would make the most sense. Instead, the one and only purpose of those scripts were to set the structure limits of some structure. Using setStructureLimits() on player zero. All that magic starts in startLimitScreen() in multilimit.cpp.Per wrote: When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
- Berserk Cyborg
- Code contributor
- Posts: 938
- Joined: 26 Sep 2016, 19:56
Re: Tech level and limiter scripts to JS
Here is the tech level conversion. I'll leave this here for a quick review to spot any potential problems.
Edit: Now in d31f6a2c704ada8f46957a34279af78deafdeec7.
Edit: Now in d31f6a2c704ada8f46957a34279af78deafdeec7.
Re: Tech level and limiter scripts to JS
Ok, see my attempt to fix this in https://github.com/perim/warzone2100/co ... fbc9794fd6Berserk Cyborg wrote:That would make the most sense. Instead, the one and only purpose of those scripts were to set the structure limits of some structure. Using setStructureLimits() on player zero. All that magic starts in startLimitScreen() in multilimit.cpp.Per wrote:When it comes to limits... I don't really understand why this is in scripts in the first place? Shouldn't there just be some field in structure.json that says "let the player limit this building in the limits screen", eg "limitable": true or something?
This patch simplifies the code quite a bit, and allows us to set a default limit that is different from the maximum. I'm not sure if and how limits are used in campaign / tutorial, though.
Re: Tech level and limiter scripts to JS
Looks good to me.Berserk Cyborg wrote:Here is the tech level conversion. I'll leave this here for a quick review to spot any potential problems.
Edit: Now in d31f6a2c704ada8f46957a34279af78deafdeec7.
- Berserk Cyborg
- Code contributor
- Posts: 938
- Joined: 26 Sep 2016, 19:56
Re: Tech level and limiter scripts to JS
Don't need data/mp/multiplay/script/multilim.slo in Potfiles.in anymore. Other than that looks good.Per wrote: Ok, see my attempt to fix this in https://github.com/perim/warzone2100/co ... fbc9794fd6
This patch simplifies the code quite a bit, and allows us to set a default limit that is different from the maximum. I'm not sure if and how limits are used in campaign / tutorial, though.
Campaign's rule.js calls setStructureLimits on eventStartLevel (should be the same amounts as multiplayer). Tutorial basically sets the max limits to 1 for the standard buildings in its eventStartLevel.
- Berserk Cyborg
- Code contributor
- Posts: 938
- Joined: 26 Sep 2016, 19:56
Re: Tech level and limiter scripts to JS
The limiting does not play nice with campaign transitions (Alpha to Beta). I thought structures were destroyed upon transition?
Re: Tech level and limiter scripts to JS
Ooops. Fixed in 9c272aa528bab38fb8d598a7f2676745ca347a4b. Structures are destroyed, but not the structure definitions - where the limits are stored now. Added a reset.Berserk Cyborg wrote:The limiting does not play nice with campaign transitions (Alpha to Beta). I thought structures were destroyed upon transition?