The Lua script does not work for me. I have to enter the ammo level via console and only then it works. I have already entered the mod in the “mods” text document in the mods folder but without success. Is there a solution here?
So, if anyone is wondering: The current mod is not working properly. It causes Lua exceptions and only works if you're using the console Command (ex: "AmmoModifier 2"). I changed the script a little and fixed some errors. Please keep in mind that i have no real experience with Lua, so there might be some bugs i missed.
Before doing anything, make sure to check if there is an update for this mod. If the update is newer than this message (posted on 2025-04-26), ignore it and just download the mod :D
Anyway, since i can't upload anything here, please follow these steps:
After installing the mod, go to "Remnant2\Remnant2\Binaries\Win64\Mods\AmmoModifier\Scripts" and open "main.lua" in any text editor
Go to this link, copy the whole text and overwrite everything in "main.lua": https://pastebin.com/GT0VQExB
Save and start the game. Check "UE4SS.log" in "Remnant2\Remnant2\Binaries\Win64" for any exceptrions or other error messages.
If you see something like "[Lua] [AmmoModifier] Successfully registered OnBeginTravel hook" in the log after spawning into the world, the script loaded just fine. A message like "[Lua] [AmmoModifier] PlayerController not found, could not change ammo drop values" is expected, don't worry about that.
I hope this helps!
Have fun!
Technical FYI for anyone interested: I corrected the function name from Ammomodifier to AmmoModifier to avoid errors caused by Lua's case sensitivity and make it look nicer. I also moved critical operations such as applying the ammo modifications and registering hooks into ExecuteInGameThread, ensuring they are only called once the engine and PlayerController are fully initialized (Thanks to Eralyne and their mod "Trait Cap Increase". It was a handy reference!). Additionally, I improved error handling around RegisterHook by properly capturing all return values with pcall and checking them before proceeding, preventing crashes if the hook target is not available. I also made sure to unregister existing hooks safely before setting new ones, and added clearer logging throughout the script to better trace what happens during execution. I have no idea if it's needed to set those values each time OnBeginTravel is called but infarctus did that and who am i to change that?
How does this mod work with co-op? I game with my brother and ammo management is a bit... yeah... so this mod looks like it would be a pretty great fix if it works.
This mod was working really well, but seems to randomly just stop working or only provide ammo drops for one weapon and not the other, it's weird. This is the only mod I have.
I am having an issue after enabling this mod where half the guns in my inventory say Dmg: 0 RPS: Nan Magazine: 0 and they are unusable? I also installed No Sway, No Recoil at the same time but am assuming the mod that changed ammo would probably be the cause?
Is there any chance you could add a setting to disable ammo drops completely? Sometimes I run with an infinite ammo mod enabled and I'd prefer ammo to just not drop at all in those cases. Mostly because I'd just rather not see the ammo drops, but also because sometimes the ammo drop will be in the same exact place as an item I do want to pick up, and I can't pick up the item because it always tries to pick up the ammo drop first.
I've tried messing around with the existing config in your mod, like setting the chance value to 0, or setting the chance value to 100 with weightedchancefornoammo set at 1 and all other weights set at 0. Unfortunately no matter what I try ammo is still dropping.
20 comments
I changed the script a little and fixed some errors. Please keep in mind that i have no real experience with Lua, so there might be some bugs i missed.
Before doing anything, make sure to check if there is an update for this mod. If the update is newer than this message (posted on 2025-04-26), ignore it and just download the mod :D
Anyway, since i can't upload anything here, please follow these steps:
I hope this helps!
Have fun!
Technical FYI for anyone interested:
I corrected the function name from Ammomodifier to AmmoModifier to avoid errors caused by Lua's case sensitivity and make it look nicer. I also moved critical operations such as applying the ammo modifications and registering hooks into ExecuteInGameThread, ensuring they are only called once the engine and PlayerController are fully initialized (Thanks to Eralyne and their mod "Trait Cap Increase". It was a handy reference!). Additionally, I improved error handling around RegisterHook by properly capturing all return values with pcall and checking them before proceeding, preventing crashes if the hook target is not available. I also made sure to unregister existing hooks safely before setting new ones, and added clearer logging throughout the script to better trace what happens during execution. I have no idea if it's needed to set those values each time OnBeginTravel is called but infarctus did that and who am i to change that?
And yes, everytime a new area loads I needed to reapply the changes so you have to change values everytime on OnBeginTravel event
This is the only mod I have.
Dmg: 0
RPS: Nan
Magazine: 0
and they are unusable?
I also installed No Sway, No Recoil at the same time but am assuming the mod that changed ammo would probably be the cause?
I've tried messing around with the existing config in your mod, like setting the chance value to 0, or setting the chance value to 100 with weightedchancefornoammo set at 1 and all other weights set at 0. Unfortunately no matter what I try ammo is still dropping.