Jump to content

Help! is this because of code change or is the mod loader broken?


Banjo

Recommended Posts

Hopefully someone can provide a quick answer to keep me from tearing my hair out! :)

 

I've come back to PZ after a while and suddenly find my mods (mostly made by me, but some downloaded ones too) no longer work.

 

I'm on the private beta "iwillbackupmysaves" (I think it's called) and the game displays "Build 19".

 

Some mods, like NecroForge, work for me. But some, mostly start spawn or item adding mods, do "nothing", even though they have ids and show up to be activated/deactivated fine in the modloader.

 

For example, I made the following quick mod for testing:

BanjoCheatersLoadout = {}BanjoCheatersLoadout.GiveCheatersLoadoutItems = function()	local player = getSpecificPlayer(0);	local playerData = player:getModData();	playerData.HasBanjoCheatersLoadoutItems = playerData.HasBanjoCheatersLoadoutItems or "false";	if(playerData.HasBanjoStarterItemsCheat == "false") then		player:getInventory():AddItem("Base.Axe");		player:getInventory():AddItem("Base.Hammer");		player:getInventory():AddItem("Base.Saw");		player:getInventory():AddItem("Base.Screwdriver");		player:getInventory():AddItem("Base.Torch");		player:getInventory():AddItem("Base.Battery");		player:getInventory():AddItem("Base.TinOpener");		player:getInventory():AddItem("Base.Lighter");		player:getInventory():AddItem("camping.CampingTentKit");		player:getInventory():AddItem("Base.BathTowel");		player:getInventory():AddItem("Base.WaterBottleFull");		player:getInventory():AddItem("Base.WaterBottleFull");		player:getInventory():AddItem("Base.TinnedSoup");		player:getInventory():AddItem("Base.TinnedSoup");		player:getInventory():AddItem("Base.TinnedSoup");		player:getInventory():AddItem("Base.Nails");		player:getInventory():AddItem("Base.Nails");		player:getInventory():AddItem("Base.Nails");		player:getInventory():AddItem("Base.Nails");		player:getInventory():AddItem("Base.Sheet");		player:getInventory():AddItem("Base.Sheet");		player:getInventory():AddItem("Base.Sheet");		player:getInventory():AddItem("Base.ShotgunSawnoff");		player:getInventory():AddItem("Base.ShotgunShells");		player:getInventory():AddItem("Base.ShotgunShells");		player:getInventory():AddItem("Base.ShotgunShells");		player:getInventory():AddItem("Base.BigHikingBag");		player:getInventory():AddItem("Base.Duffelbag");		playerData.HasBanjoCheatersLoadoutItems = "true";	endendEvents.OnGameStart.Add(BanjoCheatersLoadout.GiveCheatersLoadoutItems);

This used to load fine in the old Steam build several months ago, but now loading it with the modloader does nothing; no extra items are added to inventory on starting a new game.

 

Likewise, my 'start spawn' mods here (the product of days of coordinate research!) no longer "do anything" either; the default start locations are used.

 

At first, I assumed (because I hit the issue with my start spawn mods first) that the game's code had been changed, and thus I'd just have to find out how to re-code my mod to make it work (likely because of the addition of West Point as a map option). But the fact that the above item spwaner mod doesn't work either makes me wonder if something is bugged instead/as well.

 

Can someone confirm for me if there's a problem with my code (here and in my start spawn mods) and/or if they've had trouble with the new Steam beta not loading other such mods for them, too?

 

I don't mind reworking my mods (if someone can point the way!) but I'd hate to spend days trying to fix them only to find out it was the beta itself that was bugged! :)

Link to comment
Share on other sites

The spawn point have changed a bit due to West point (you now have 2 lists, one for Muldraugh, one for WP), check the MainCreatioNmethods.lua to see how it works.

 

Also, for the example you gave, looks good to me, can you provide me a .zip with everything to test ? Will look if it's a mod loader problem or nope (you should see you .lua file loaded in the console on startup)

Link to comment
Share on other sites

The spawn point have changed a bit due to West point (you now have 2 lists, one for Muldraugh, one for WP), check the MainCreatioNmethods.lua to see how it works.

 

Also, for the example you gave, looks good to me, can you provide me a .zip with everything to test ? Will look if it's a mod loader problem or nope (you should see you .lua file loaded in the console on startup)

Thanks for the quick reply!

 

I suspected that was the reason for the start spawn mod problems, and will happily look into fixing them.

 

I've attached my test mod (removed since now fixed) here; when checking the PZ console window (by running 'ProjectZomboid32.bat', since the console no longer appears normally when I just run the game from Steam?), the mod's .lua IS loaded it seems, but on starting a new game my character never receives the bunch of items I expect, as they used to in previous PZ versions with this mod (2.99.17, if I recall was the last I tested on that worked).

 

Anyway, thanks again for looking into this, mate... you're an absolute legend here, you know? :)

 

(re: the 'West Point or Muldraugh' buttons when starting a new game, without going into too much detail, does this mean that it might be possible to make our own 'choose a start location' button mod too?)

Link to comment
Share on other sites

Hello,

 

So, couple of things.

 

The modData is a table, not an object (tho a table is an object.. Erm wait :D), mean we only save modData["stuff"] and not modData.stuff.

 

Then, you used "HasBanjoCheatersLoadoutItems" at first, but your test to spawn item is : if(playerData.HasBanjoStarterItemsCheat == "false") then

So it should be : if(playerData["HasBanjoCheatersLoadoutItems"] == "false") then

Because it's not the same variable you used (HasBanjoCheatersLoadoutItems/HasBanjoStarterItemsCheat), and it's a table (the ["stuff"] thingy).

 

Also, there is an event specially for new game only : OnNewGame, use it instead of your trick :)

 

Because i'm a fun guy, here's the code fixed (but you really should use OnNewGame :D) :

 

Spoiler

 

Don't hesitate to add "print" function everywhere to check if your mod is loaded, to debug the variables you use, etc.

Also, press F11 (default key) to bring the lua debugger add break point, it's really helpfull to see what's wrong :)

 

Cheers !

Link to comment
Share on other sites

Thanks so much for the help, mate! That works just like it used to!

 

I forget who kindly taught me to do the previous method, but it worked fine before. Perhaps it was more 'hacky' and thus subsequent code tidy-ups/fixes are why it stopped working.

 

Does "OnNewGame" only fire on... well, a newly started game (i.e. not on loading a saved game)? That's very useful if so, but in the case of this mod, I'd want it to check on loading saves too, so the player can conceivably activate the mod and gain the items on a save in progress as well as a brand new game.

 

Just because I'm now fixing my start spawn mods, can I be a pest and repeat my "is it possible to add another (third) start location selection button via a mod" to the Muldraugh/West Point list for new games? Such the stuff controlled (I presume) by "MapSelector.lua"? This would negate the need to override spawning with a mod (such as my 'Dixie Mobile Park' one), is why I'm asking.

Link to comment
Share on other sites

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