[MOD 0.12.11+] AmmoBox 0.3.0 - Fun with Turrets & Logistics

Topics and discussion about specific mods
User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

[MOD 0.12.11+] AmmoBox 0.3.0 - Fun with Turrets & Logistics

Post by Afforess »

Type: Mod
Name: AmmoBox
Description: Adds large ammo boxes, compacted ammo magazines for turrets, & Mk2 Gun Turret with logistics slots.
License: MIT License
Version: 0.3.0
Release: 2016-1-30
Tested-With-Factorio-Version: 0.12.22
Category: Item
Tags: Ammo, Turrets, Logistics
Download-Url: https://github.com/Afforess/AmmoBox/rel ... _0.3.0.zip
Website: https://github.com/Afforess/AmmoBox
Extras Addons: AmmoBox AutoRequest Mod by daydev
License
Long description
Pictures
Version history
Previous Releases
Last edited by Afforess on Wed Feb 10, 2016 4:00 am, edited 17 times in total.

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

Re: [MOD 0.12.x] AmmoBox

Post by Adil »

Good job.
I wanted to do that too. :(
Can we have a discussion?

I didn't know create_entity can spawn colliding entities together, probably that will get fixed someday.

You can group events with same handlers together like this:

Code: Select all

game.on_event({defines.events.on_built_entity,defines.events.on_robot_built_entity},function(event) ... end)
Speaking of which on_robot_built_entity handler is bugged as it lacks the line 7 from on_built_entity.

Both tooltips can be made accessible by changing selection boxes of entities. Say logistic container might have selection_box = {{-1, -1 }, {0, 1}}, and the gun - {{0,1 }, {1, 1}}.

Same goes to collision boxes. In a fact I'd make the gun non-colliding at all, by setting collision_mask={}.
And probably make chest invincible while gun lives instead of constantly updating its health.
As a continuation of previous, I'd say that this tandem creation should be initiated by placing the logistic container rather than by placing gun turret. That way blueprints would preserve requester conditions (but all item tooltips would not provide gun-power info).
Alternatively, requester might be made into standalone module that can be placed over turret (like my unloader mods).

Also, is it really necessary to sync every turret-chest pair sixty times a second?
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
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by Afforess »

Adil wrote:Good job.
I wanted to do that too. :(
Can we have a discussion?
Absolutely! No reason you can't contribute to the project on github, btw. I try not to be one of those people who think their code is some work of art that shouldn't be modified or criticized by others. Code is code, and plenty of mine is not so great. ;)
Adil wrote: I didn't know create_entity can spawn colliding entities together, probably that will get fixed someday.
I agree, it is a bit of a hack. No idea if they will fix it, but it works for now.
Adil wrote: You can group events with same handlers together like this:

Code: Select all

game.on_event({defines.events.on_built_entity,defines.events.on_robot_built_entity},function(event) ... end)
Nice, I did not know that. I am not super-familiar with lua, or the factorio API.
Adil wrote:Speaking of which on_robot_built_entity handler is bugged as it lacks the line 7 from on_built_entity.
Ouch, yes. It shouldn't be player.force... I need to check the API to see what it should be. entity.force?
Adil wrote:Both tooltips can be made accessible by changing selection boxes of entities. Say logistic container might have selection_box = {{-1, -1 }, {0, 1}}, and the gun - {{0,1 }, {1, 1}}.
Oh, very good. That solves one of my primary issues.
Adil wrote:Same goes to collision boxes. In a fact I'd make the gun non-colliding at all, by setting collision_mask={}.
And probably make chest invincible while gun lives instead of constantly updating its health.
Yeah. Both are good suggestions, I will test an implementation later tonight.
Adil wrote:As a continuation of previous, I'd say that this tandem creation should be initiated by placing the logistic container rather than by placing gun turret. That way blueprints would preserve requester conditions (but all item tooltips would not provide gun-power info).
Alternatively, requester might be made into standalone module that can be placed over turret (like my unloader mods).
That is a really good point. The reason I had the gun turret placed first was so you could access the requester inventory, as that entity was on top. But if changing the selection boxes and collision boxes makes it possible to hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Adil wrote:Also, is it really necessary to sync every turret-chest pair sixty times a second?
I really didn't want to do that, but I'm not aware of any events that fire when health or inventory changes. I did my best to try to minimize the per-tick impact, but obviously it could be better. If I made it update only update every 5 or 10 ticks, then I would run into the possibility that health or ammo would become out of sync enough that the turret could die, or ammo run out.

User avatar
Xterminator
Filter Inserter
Filter Inserter
Posts: 981
Joined: Sun Jun 15, 2014 4:49 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by Xterminator »

Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets. :D

Mind if I do a mod spotlight on this in the near future?
Image Image Image

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

Re: [MOD 0.12.x] AmmoBox

Post by Adil »

Afforess wrote: Absolutely! No reason you can't contribute to the project on github, btw.
Yeah, one day I will get around registering there. :?
Afforess wrote: hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Tooltip is shown when you select entity. I doubt you can get it from completely hidden object. Suggested selection boxes would just allow you to select chest when hovering cursor over the left side of entity, and gun when over right.
Afforess wrote: If I made it update only update every 5 or 10 ticks, then I would run into the possibility that health or ammo would become out of sync enough that the turret could die,
There is on_entity died event for that.
Afforess wrote: or ammo run out.
Not that I'd see that as a problem (provided it is not happenning each time turret shoots).
Turret shoots 10 bullets/second, that's 1 clip/second, updates hardly need to happen more often than that, though then it'll need to load more than a single clip per check. With bullet speed upgrades it wastes 2 clips/sec but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)


By the way, your turrets are not affected by the gun-turret upgrades and thus vanilla overpower them after all upgrades.
The following would put them in upgrades.
data-upgrades.lua
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
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by Afforess »

Xterminator wrote:Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets. :D

Mind if I do a mod spotlight on this in the near future?
Sure. You might want to hold off a day or two until I can fix the bugs Adil has mentioned, but absolutely.
Adil wrote:
Afforess wrote: Absolutely! No reason you can't contribute to the project on github, btw.
Yeah, one day I will get around registering there. :?
Afforess wrote: hide the gun while showing it's tooltip, then there will be no reason to have the gun turret placed first anymore.
Tooltip is shown when you select entity. I doubt you can get it from completely hidden object. Suggested selection boxes would just allow you to select chest when hovering cursor over the left side of entity, and gun when over right.
Ahh... I see.
Adil wrote: Not that I'd see that as a problem (provided it is not happenning each time turret shoots).
Turret shoots 10 bullets/second, that's 1 clip/second, updates hardly need to happen more often than that, though then it'll need to load more than a single clip per check. With bullet speed upgrades it wastes 2 clips/sec but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)
So basically, I could update the turrets every 30 ticks instead of every tick? Sounds like a good idea.
Adil wrote: By the way, your turrets are not affected by the gun-turret upgrades and thus vanilla overpower them after all upgrades.
The following would put them in upgrades.
data-upgrades.lua
Very helpful! With all your suggestions, I might just have to cite you as a contributor, :P
Adil wrote: but it's not far-fetched assumption that by the time ammoboxes would be used. (Though I myself am usually against such items.)
I can definitely see the argument both ways, and I do worry it could be unbalanced. I tried to make the ammo boxes expensive, but I realize that never fully makes up for the extra ammo. I just think this particular case is an exception because Gun Turrets / Regular Ammo are already so underpowered, that a bit of a boost does not hurt.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by Afforess »

Xterminator wrote:Really cool idea! Having a turret with a built in Logistic request slot is brilliant, and surprised it hasn't been done yet. The ammo boxes are pretty awesome too, especially for turrets. :D

Mind if I do a mod spotlight on this in the near future?
Issues should be fixed now, feel free to spotlight this whenever you have time. ;)

Many thanks to Aldi for the suggestions & improvements.

capthavic
Inserter
Inserter
Posts: 30
Joined: Tue Oct 13, 2015 10:05 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by capthavic »

Update today broke the mod. Any chance of getting an patch for it?

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox

Post by Afforess »

capthavic wrote:Update today broke the mod. Any chance of getting an patch for it?
I will take a look in a few hours.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.3

Post by Afforess »

AmmoBox 0.1.3 is released, fixing the issues introduced in Factorio 0.12.11. For users of previous versions of Factorio, I have added a link to previous releases. ;)

capthavic
Inserter
Inserter
Posts: 30
Joined: Tue Oct 13, 2015 10:05 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.3

Post by capthavic »

Cool, thanks! ^w^

User avatar
Darkestnoir
Inserter
Inserter
Posts: 29
Joined: Sun Nov 23, 2014 8:57 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.3

Post by Darkestnoir »

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:103: attempt to call field 'get_inventory' (a nil value)
Getting this when i load my 12.13 save...

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.3

Post by Afforess »

Darkestnoir wrote:

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:103: attempt to call field 'get_inventory' (a nil value)
Getting this when i load my 12.13 save...
Thanks for the report! I will take a look and release a fix later tonight.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.3

Post by Afforess »

Darkestnoir wrote:

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:103: attempt to call field 'get_inventory' (a nil value)
Getting this when i load my 12.13 save...
This should be fixed in 0.1.4! :D

User avatar
Darkestnoir
Inserter
Inserter
Posts: 29
Joined: Sun Nov 23, 2014 8:57 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.4

Post by Darkestnoir »

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:133: petroleum-generator doesn't have an inventory with index(1)
A new "Game Breaking Bug", with 12.14 :D

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.4

Post by Afforess »

Darkestnoir wrote:

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:133: petroleum-generator doesn't have an inventory with index(1)
A new "Game Breaking Bug", with 12.14 :D
Factorio 0.12.14 is totally broken, don't use it.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.1.4

Post by Afforess »

Darkestnoir wrote:

Code: Select all

Error while running the event handler: __AmmoBox__/control.lua:133: petroleum-generator doesn't have an inventory with index(1)
A new "Game Breaking Bug", with 12.14 :D
As long as you are on AmmoBox 0.1.4 and Factorio 0.12.15, you shouldn't see this. If you do, provide a save & zip of mods.

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.2.0

Post by Afforess »

AmmoBox 0.2.0 released. Changes:

v0.2.0 (1-11-2015):
  • Add compressed flamethrower ammo
    • Holds 100x magazine size of standard flame thrower ammo
    • Has 2x attack distance of regular flamethrower ammo
    • Requires Flamethrowers 2 tech to unlock
  • Added flamethrower 2 tech to unlock compressed flamethrower ammo

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: [MOD 0.12.x] AmmoBox 0.2.1

Post by Afforess »

Minor patch release 0.2.1. Fixed some missing locale text for gun turret 2 in the tech description.

callmewoof
Inserter
Inserter
Posts: 27
Joined: Fri Apr 24, 2015 3:46 am
Contact:

Re: [MOD 0.12.x] AmmoBox 0.2.1

Post by callmewoof »

I appreciate the mod! I was wondering though after looking at the files, is there a reason it needs to be so complicated? Like, what's with the logger stuff? Isn't the principal of requesters built into the base game? I know it isn't literally that simple, but in the end an object is just saying "hey I have 1 requester slot, FYI". I hope that doesn't sound rude, I mean the mod works and again thanks, but what's the hurdle from it being much simpler? I'm sure I'm missing something, probably obvious, so I appreciate if you/anyone can answer. Thanks!

Post Reply

Return to “Mods”