Hardcore Start

by ouk_ouk

Removes the default items in from player's inventory on spawn/respawn. (Possible to configure to remove only weapons or leave only them.) Before disabling/removing this mod, restore the default items on all your saves. (Load the save, change mod settings and save again.)

1 year, 6 months ago
0.16 - 1.1
2553

b No empty inventory with "Angel's Refining" (and "Amator Phasma's Coal & Steam")

2 years ago
(updated 2 years ago)

Upon installing and using the mod "Angel's Refining" with your mod,
you still have 1 burner ore crusher in your inventory.
Also, when using "Angel's Refining" and "Amator Phasma's Coal & Steam" together,
"Amator Phasma's Coal & Steam" adds additional items to your inventory as well, without getting cleared.

Without using "Angel's Refining" at all, the other mod works as expected, means, you have an empty inventory

By appending the dependency line with this:
"? angelsrefining >= 0.10.14", "? apm_power >= 0.18.21"
the problem does not occur anymore.
But I don't know, whether it's the right approach to fix this bug, as I have no modding experience in Factorio.

Thank you for reading my bug report and have a nice day!

Edit:
Also, the game crashes, if I load up the sandbox scenario, because the user controls no character in this scenario.

2 years ago

The bug with sandbox is fixed.
I don't think I gonna do anything about items from other mods. I don't have any idea how to do that other than listing all mods, that can add items to start inventory, in the dependency list. As you've suspected, this is not a very clean approach.
Let's just say this mod is for vanilla Factorio and if anybody wants to apply it to other mods, they can do it the way you did.

2 years ago

I don't think I gonna do anything about items from other mods. I don't have any idea how to do that other than listing all mods, that can add items to start inventory, in the dependency list.

This is just about starting a game, right? So you could do this in on_player_created():

  • Loop over all players.
  • Get the character associated with a player.
  • Use get_inventory(inventory) to get the different inventories of each character. According to the API description, these inventories could be relevant:
    defines.inventory.character_main
    defines.inventory.character_guns
    defines.inventory.character_ammo
    defines.inventory.character_armor
    defines.inventory.character_vehicle
    defines.inventory.character_trash
  • Loop over the different inventories and use inventory.clear() to remove all items.

I haven't tested this, but that's how I would try to solve that problem. :-)

2 years ago
(updated 2 years ago)

Thank you for trying to help, Pi-C.

But I think this mod does that, what you described in your post. The only difference is, instead of searching every slot the character has, this uses this simple command on the player to clear the entire inventory.

The problem right know is the loading order. If mods, which have on_player_created() events and use this to add new items to the player's inventory, are loaded after this mod, the "clear_items_inside"-command is executed too early (before the items are added to the player's inventory by the said mods), which results in a player still having items.

Edit:
After a quick research, it seems like using the optional dependency-method to change the mod load order is the only way to achieve a clean inventory with the on_player_created()-event. Another (ugly) way would be to use the on_nth_tick() event as well, setting some kind of variable in on_player_created-event, waiting one tick (or longer), reset the variable, unregister the on_nth_tick()-event so it doesn't constantly fire again and finally clear the inventory.

Edit2:
Actually, I don't think you need that variable at all I think.

2 years ago
(updated 2 years ago)

Jeez, I wanted to be lazy about this mod ;-)

I guess the idea with delaying the cleanup one tick could work but I have feeling that it would clash horribly with some other mod, creating some weird, hard to fix error, after some unspecified amount of time when it works perfectly. (It's just a feeling but experience tells me nothing is ever simple.)

For now I asked on the forum and we'll see what will happen.

2 years ago
(updated 2 years ago)

Hmm, I guess "on_player_created" and "on_player_respawned" are the same ? Because on the forum, you wrote "on_player_respawned", even though you use the other one in this mod. I thought "on_player_created" would be called once, when first-time joining a new world, so the risk of getting an error would be slim, as you only have to execute a cleaning command. But on the other hand, I am not experienced enough in modding, so it could be wrong.

(Maybe, the only thing to keep in mind with the one-tick-trick is to check, if a player still exists after one tick or if you are precise enough to save and close a world between "on_player_created" event and one tick after, so you won't lose your items through the one-tick-trick, when you reload that world. But this is very very unlikely, impossible I would say, that the said scenarios will happen. So I guess you can ignore this paragraph :) .)

Anyway, I wish you good luck finding a clean solution, which you can be satisfied with.

2 years ago

I think I took this snippet for the forum from the other mod.

2 years ago
(updated 2 years ago)

Oh okay then :)
I think the to-be-found solution could be applied to this mod as well, since the events "on_player_respawned" and "on_player_created" are similar to each other.

1 year, 6 months ago

OK, I'm back from the limbo. I'm currently rewriting the mod to use interface "freeplay" => "set_created_items" (and "set_respawn_items" for the other mod).
There are some problems because I would like to be able to turn off the mod in any moment and if you use those setters once they stay, even if you reload the game without the mod. I'll try to solve it. In a few days I should have a solution.

1 year, 6 months ago

The version 1.1 is ready and it is a complete rewrite of the one for 0.18. Done much more by the book and it affects only the Freeplay scenario now.
After those changes it seem to handle items from those two mods correctly. It may depend of the order of execution mods so let me know it you stumble upon some mod that is not compatible. I'll try to do something about it.

New response