Page 1 of 1

Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 12:21 am
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?

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 12:27 am
by Adil
By finding `insert` in the mod code and commenting it?

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 12:30 am
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.

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 1:26 pm
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.

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 1:32 pm
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

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 3:13 pm
by Ranakastrasz
How do I distinguish between player and automatic action?

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 3:54 pm
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

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 3:56 pm
by Nexela
You could watch for cursor stack changed and only stop the filling if the item wasn't in the cursor

Re: Disable Auto-reload Ammo

Posted: Fri Sep 23, 2016 4:34 pm
by Adil
shift-click doesn't count as cursor stack change
yet it can be used for reloading.