Disable Auto-reload Ammo

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2144
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Disable Auto-reload Ammo

Post by Ranakastrasz »

I am trying the "Hardcorio" Mod. Among other things, I think that the vanilla game didn't originally automatically put ammo back into your guns when you depleted, which given how the mod's weapons were setup, seems to have been taken advantage of.

How might I go about reverting this behavior, if possible?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Disable Auto-reload Ammo

Post by Adil »

By finding `insert` in the mod code and commenting it?
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2144
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Disable Auto-reload Ammo

Post by Ranakastrasz »

I meant that it was a vanilla feature I wanted to disable to add on to the mod. Its not part of the mod so far as I can tell.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Disable Auto-reload Ammo

Post by Adil »

Oh, vanilla when your ammo slot is depleted, if there's more of the same type of ammo in the inventory, then it is automatically inserted into gun.

If you're looking to prevent that, I don't know, any solution I can think of is more trouble than it's worth.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5156
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Disable Auto-reload Ammo

Post by Klonan »

Adil wrote:Oh, vanilla when your ammo slot is depleted, if there's more of the same type of ammo in the inventory, then it is automatically inserted into gun.

If you're looking to prevent that, I don't know, any solution I can think of is more trouble than it's worth.

Code: Select all

script.on_event(defines.events.on_player_gun_inventory_changed, function (event)
  remove_ammo_stack_or_something(game.players[event.player_index]
end)

function remove_ammo_stack_or_something(player)
  do some logic to move the stack back to the main inventory
end

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2144
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Disable Auto-reload Ammo

Post by Ranakastrasz »

How do I distinguish between player and automatic action?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Disable Auto-reload Ammo

Post by aubergine18 »

See if you get this event beforehand, also I don't think robots can place ammo in the ammo slots, only main inventory slots.

http://lua-api.factorio.com/latest/even ... ck_changed
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Disable Auto-reload Ammo

Post by Nexela »

You could watch for cursor stack changed and only stop the filling if the item wasn't in the cursor

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Disable Auto-reload Ammo

Post by Adil »

shift-click doesn't count as cursor stack change
yet it can be used for reloading.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”