Jump to content

Arcalane

Recommended Posts

So I made a nice functional little mod which adds a bunch of zombie outfits the spawn pools, based off another mod. That's all working great. But I'm trying to expand the functionality right now and I'm running into a really weird and frustrating issue.

 

The thing is, I want to add spawn chance multipliers and a couple of booleans as sandboxvars that control whether certain behaviours run or not. Now, so far as I can tell all of this code should work but the game is completely ignoring any changes to the settings themselves.

 

Take, for instance, this block;

ExosEnabled = 0
if SandboxVars.ArcStalkerOutfits.ExoZombies == true then
	noise('Exo Zombie Spawns: Enabled')
	ExosEnabled = 1
end

Simple enough, right? ExosEnabled serves as a final multiplier to the chance of all zombies of a specific type. It defaults to x0, and if the sandbox option is true then it prints a message to the console/log that says they're enabled and sets the multiplier to x1. A few lines later, the base spawn chance is multiplied by the faction spawn chance, and then by the ExosEnabled value - and anything multiplied by zero equals zero, so the chance of ever seeing those types of zombies in the wild should be... zero.

 

But here's the kicker; the sandboxvar defaults to true, and even if I uncheck the box so that it's false it still acts like it's true and prints the message to the console/log. The only way it actually stops doing that is if I set the default value of the sandboxvar to false in the sandbox-options.txt. And even then, it still apparently treats ExosEnabled as 1, because I'm still able to find that zombie type in the world by random chance.

 

Worse, it's also treating every other sandboxvar added by the mod as 1, and for some reason if I try to print their value to the console they come back as blank.

 

Everything else works, there's no compile errors in the console, nothing like that. The sandbox options are just being completely ignored for reasons I can't fathom. Are they just busted to the point I should use Mod Options or Easy Config? Is there some trick I'm missing? Have all mod SandboxVars secretly been FUBAR this entire time and somehow nobody's noticed?

Link to comment
Share on other sites

I've had issues with andbox settings, I *think* they're only guaranteed to exist after a save has loaded.

To get around this, I did this:

 

local function OnWeaponHitCharacter(player, target, handWeapon, damage)	
	player:setHaloNote(string.format("%.1f", damage))
end

local function OnLoad()
	if(SandboxVars.Hydrocraft.ShowDamage ~= nil and SandboxVars.Hydrocraft.ShowDamage == true) then
		Events.OnWeaponHitCharacter.Add(OnWeaponHitCharacter)
	end
end

Events.OnLoad.Add(OnLoad)

 

Link to comment
Share on other sites

On 8/1/2022 at 12:42 PM, Hugo Qwerty said:

I've had issues with andbox settings, I *think* they're only guaranteed to exist after a save has loaded.

Where's a psyduck emoji when you need one... eugh.

 

 

 

I'm not entirely sure that's the case. I've tweaked the print values and am getting them to return the actual info "properly". I say properly with giant airquotes because all of the spawn multipliers are returning 1 regardless of what I set.

 

More oddly, the UI is displaying the values I set during game setup, but when I exit to the main menu and reload the save I always get the default values back from the console.

 

This is what I've set them to;

sandbox_options.png.9b09d7fde039c39625111f58fbb778ce.png

 

But this is what the console tells me;

LOG  : General     , 1659445277193> SZZD.lua: Extra Zone Spawns: Enabled
LOG  : General     , 1659445277193> SZZD.lua: Loner Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277193> SZZD.lua: Bandit Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Duty Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Freedom Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Clear Sky Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Ecologist Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Military Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Monolith Spawn Multiplier: 	1	x.
LOG  : General     , 1659445277194> SZZD.lua: Merc Spawn Multiplier: 	1	x.

This seems fishier than a wet market. My hunch is that they're not being saved properly and are being read from the mod's base sandbox-options.txt each time rather than from the save's data, but that doesn't explain why it observes the toggle to disable Zombified Exoskeletons but then allows them to spawn anyways.

Edited by Arcalane
slight clarification
Link to comment
Share on other sites

Yeah, okay, now it's returning the correct values. I guess shoving everything into an on load function might be required.

 

The problem then is that this mod also uses table.insert to, well, insert entries into the spawn tables, since I didn't want to do a messy overwrite that could cause incompatibilities with other mods. I'm not gonna run into any weird situations where the spawn tables are slowly but surely filled up by extra entries over multiple loads of the save, am I? 🤔

 

Ed: been doing some experiments with OnLoad - it seems to be working better than before, but not flawlessly. Namely, some spawns are still able to occur even though the multiplier is set to 0, though I am experimenting with a fix for that. (Ed: Looks like that fix works.) It also doesn't seem to apply effects on "first run" - I'm guessing I want OnGameStart for this instead?

 

Ed2: OnGameStart seems to be working... basically exactly the same as OnLoad. Ah well.

 

Ed3: Whilst both modes work fine for singleplayer, neither option is working for locally-hosted games; it doesn't do the table.insert work properly. Console tells me that the function is running, but it's clearly not doing anything since the new zombies don't spawn unless I use the horde manager to spawn that outfit/uniform specifically.

Edited by Arcalane
experiment progress 3
Link to comment
Share on other sites

  • 2 weeks later...

Anyone got any ideas for this? I've tried using Finn's Easy Config Chucked but that's having an issue where the config folder isn't being respected, and I can't get Mod Config Menu to work either.

 

All I want is for config on the spawns to work and be compatible with SP+Local MP+Dedicated MP.

Link to comment
Share on other sites

  • 2 weeks later...

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...