Possible collision with character bonuses being changed

Place to get help with not working mods / modding interface.
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Possible collision with character bonuses being changed

Post by Honktown »

I'm playing with two mods that can change a bonus, and I'd like help in narrowing down an issue of "the changes/values aren't happening as expected".

One mod uses the rpg system, so I'd expect only when I add points or something is triggered in that mod, my crafting speed will change.

I'm trying to update an equipment mod that changes attributes, and if I have a +/- effect on craft speed, the additions always work, but rarely, the subtraction effect was more than expected (in this case, doubled). I've logged when the event triggers (on_player_removed_equipment), and the error only seemed to happen when I removed at least two of the equipments at once (only tried two). I did a log and the event always seems to fire once, and has the proper count (2), but randomly I'll get an extra subtraction. I went into a new game with /cheat in console, but I think because it makes crafting "instant" the crafting speed modifier is disregarded, and worse, gets set to 0, so even if it increases by a custom research, there is no change. I can equip the equipment and get +, but since I can't seem to go below 0, there's no way to tell if the extra subtraction triggers at all.

Other than logging the value every tick and trying to identify when it changed and go from there, I'm wondering if anyone has any suggestions (like a logger that can find when and what/how a single monitored value was changed).

I've yet do all the basic things: I didn't think of trying to set it to 10 while in /cheat mode and go from there, so I need to try that.
I have mods! I guess!
Link
PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: Possible collision with character bonuses being changed

Post by PyroFire »

1. please post minimum setup for the conflict to happen along with steps to reproduce the issue (links to mods go a very long way here)

2. It's caused by Mod A doing .bonus=what_i_think_bonus_should_be+1 then later on, Mod B doing .bonus=no_its_what_i_think_bonus_should_be+10.
Neither mod is necessarily more right than the other.
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Possible collision with character bonuses being changed

Post by Honktown »

PyroFire wrote: Mon Dec 16, 2019 8:13 am 1. please post minimum setup for the conflict to happen along with steps to reproduce the issue (links to mods go a very long way here)

2. It's caused by Mod A doing .bonus=what_i_think_bonus_should_be+1 then later on, Mod B doing .bonus=no_its_what_i_think_bonus_should_be+10.
Neither mod is necessarily more right than the other.
https://github.com/M3wM3w/ComfyFactorio

It has multiple RPG maps, I was playing spookyforest (you have to edit the control.lua in the scenario). "Dexterity" is the attribute which increases crafting speed.

https://drive.google.com/open?id=1-NzIV ... C7WmsOTogp

red/green/blue science with some requirements, "Crafting Assistant" equipment. It takes power, so you need armor with a power source.

Bonus-technology (mod center) and Quality of Life Research (mod center) are installed. Their research effects don't change the player crafting attribute with /cheat, even though they do in a normal game.

/c game.print(game.player.character_crafting_speed_modifier)

In the spookyforest scenario my points in dexterity (and technologies) resulted in a 4.35 crafting speed modifier. If I equipped/unequipped one Crafting Assistant, my speed modifier would go up to 4.85, back down to 4.35 as expected. If I equipped two, and unequipped two with ctrl-click or shift-click (whichever it is), it would always bring my speed up to 5.35, but rarely, down to 3.35. From then on, my speed could only go up to 4.35. I'll do a quick check to see if I can get it to go down to 2.35 or lower, since I'm unsure if it did or not.
I have mods! I guess!
Link
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Possible collision with character bonuses being changed

Post by Honktown »

"Progress"!

There seems to be a timed reset of the attribute to the RPG system value, both up and down. Now to dig for it.

Whether or not it's timed, this function is the culprit:

Code: Select all

function Public.update_player_modifiers(player)
	for _, modifier in pairs(modifiers) do
		local sum_value = 0
		for _, value in pairs(this[player.index][modifier]) do
			sum_value = sum_value + value
		end
		if player.character then
			player[modifier] = sum_value
		end
	end
end
Sloppy programmers. I won't do anything about it, I was more concerned it was an issue with a mod I'm migrating.

Edit: thanks. Sometimes I need that push.
I have mods! I guess!
Link
Post Reply

Return to “Modding help”