[MOD 0.12.x] Autofill

Topics and discussion about specific mods
Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by Peter34 »

Takezu wrote:
XyLe wrote: Also i found it better for my play style having "limits" removed from turrets ammo. 10 rounds per turret doesn't seem enough for me :)
Depends if you autorefill them via inserter or not. if you use an inserter/belt combination for the turrets then 10 is just fine, it's the same amount
that the inserter trys to hold in the turret, if not then yeah the more the better.
I'm sure it's beyond modding, but dev-wise there could be various keypresses for when a Gun Turret is plonked down:

LMB: plonk down Turret, empty.
Shift+LMB: Plonk down Turret, with up to [max take, which is 10] AP Ammo if carried, otherwise up to [max take] regular Ammo.
Ctrl+LMB: Plonk down Turret, with a fraction of ammo carried (AP Ammo if any is carried, else regular Ammo), as per how the Autofill mod originally worked.
Alt+LMB: Plonk down Turret, with as much ammo as it can contain, if that much is carried (again, AP Ammo gets preference, but if none is carried, use regular Ammo instead).

User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 106
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by db48x »

Peter34 wrote:I'm sure it's beyond modding, but dev-wise there could be various keypresses for when a Gun Turret is plonked down:

LMB: plonk down Turret, empty.
Shift+LMB: Plonk down Turret, with up to [max take, which is 10] AP Ammo if carried, otherwise up to [max take] regular Ammo.
Ctrl+LMB: Plonk down Turret, with a fraction of ammo carried (AP Ammo if any is carried, else regular Ammo), as per how the Autofill mod originally worked.
Alt+LMB: Plonk down Turret, with as much ammo as it can contain, if that much is carried (again, AP Ammo gets preference, but if none is carried, use regular Ammo instead).
That would add a lot of implementation, maintenance, and documentation complexity; better to have one behavior which is reasonable and which can be extended by further actions in the game (put in the normal amount of ammunition, then the user can build inserters to continue loading the turret.)

On a subject, I've found that autoloading turrets changes the game balance quite dramatically. Taking out even a quite large base becomes a simple matter of dropping turrets as you run by. Turrets have a lot higher dps than a distractor capsule, are manufactured more cheaply and quickly, and are available earlier in the tech tree; this makes them superior in almost all cases. I haven't tried this against massed big worms though; the larger deployment distance of a distractor capsule may be the deciding factor there.

As a solution, I suggest making it take time to construct a loaded turret. I think it would be ideal if it behaved the same way as deconstructing items; a delay during which you can't otherwise act (although on second thought I believe that you can still fire you own weapons while deconstructing things) with a little progress bar to tell you that it's working. I don't think that will be simple to implement, however.

User avatar
MasterBuilder
Filter Inserter
Filter Inserter
Posts: 348
Joined: Sun Nov 23, 2014 1:22 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by MasterBuilder »

db48x wrote:As a solution, I suggest making it take time to construct a loaded turret. I think it would be ideal if it behaved the same way as deconstructing items; a delay during which you can't otherwise act (although on second thought I believe that you can still fire you own weapons while deconstructing things) with a little progress bar to tell you that it's working. I don't think that will be simple to implement, however.
This may actually be achievable. It's been a long time since I've looked at modding Factorio so I may be wrong but here're my thoughts:

Method A:
I don't think it's possible to not place an item instantly. We could however re-purpose 'mining' the turret to build it:

1: Have the user place a 'dummy' turret entity (does nothing, just same size) where they want the turret to be.
2: Have the user mine (remove) it. This should trigger a LUA event that we can handle. (I'm pretty sure there's such an event but it's been a while so I don't remember.)
3: Use the triggered event to remove the dummy entity and replace it with an actual turret & ammo.

This does however require that we stop the player from placing the regular turrets altogether. (Only allow placing the dummies. I'm not sure this is possible.) If you could get past that, well, it wouldn't be mod friendly but, in theory, it could work.
Having to mine every single turret to build it will get annoying though.

Method B:
Add a simple timed delay before ammo is actually placed in the turret. 3-5 secs should be adequate to match the time a human player (under fire) should need.

I don't think there's a way to display something above the turret though. I think UI modding is just relative to the screen. We could make a spot in the UI to show the user a list of 'building' turrets. (Which is just the delay before they get their ammo.)
Alternatively we might be able to spawn an entity above the turret and change it's color or texture to indicate readiness? Maybe make simple textures with just numbers and change the 'overlay' entity above the turret?
Give a man fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life.

User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by ThaPear »

MasterBuilder wrote:Method A:
I don't think it's possible to not place an item instantly. We could however re-purpose 'mining' the turret to build it:

1: Have the user place a 'dummy' turret entity (does nothing, just same size) where they want the turret to be.
2: Have the user mine (remove) it. This should trigger a LUA event that we can handle. (I'm pretty sure there's such an event but it's been a while so I don't remember.)
3: Use the triggered event to remove the dummy entity and replace it with an actual turret & ammo.

This does however require that we stop the player from placing the regular turrets altogether. (Only allow placing the dummies. I'm not sure this is possible.) If you could get past that, well, it wouldn't be mod friendly but, in theory, it could work.
Having to mine every single turret to build it will get annoying though.
This would make building turrets more tedious than it currently is, rendering this mod useless.
MasterBuilder wrote:Method B:
Add a simple timed delay before ammo is actually placed in the turret. 3-5 secs should be adequate to match the time a human player (under fire) should need.

I don't think there's a way to display something above the turret though. I think UI modding is just relative to the screen. We could make a spot in the UI to show the user a list of 'building' turrets. (Which is just the delay before they get their ammo.)
Alternatively we might be able to spawn an entity above the turret and change it's color or texture to indicate readiness? Maybe make simple textures with just numbers and change the 'overlay' entity above the turret?
This is the best solution if you want to create a delay. The text is easy: you can simply use this:

Code: Select all

game.createentity{name="floating-text", position=pos, text="Hello", color={r=1,g=1,b=0.5}}
Disclaimer: Probably contains errors
You can create your own floatingtext entity that does not float away and does not vanish after a while to create your own script controlled countdown.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by rk84 »

Yes. I could delay the activation of turret or the insertion of ammo, but I'm not quite sure how much and if it is worth the effort. The end result might be same, if I use tank to take initial aggro and leave trail of turrets behind?

Another possiblity to create delay is to make bots do the work (Personal roboport is coming in Factorio 0.12.x.).
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

d0cter
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jul 18, 2015 2:56 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by d0cter »

will this mod be updated to the new 0.12 version?

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by rk84 »

d0cter wrote:will this mod be updated to the new 0.12 version?
Done.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

d0cter
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Jul 18, 2015 2:56 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by d0cter »

rk84 wrote:
d0cter wrote:will this mod be updated to the new 0.12 version?
Done.
Great! tnx

cpw
Long Handed Inserter
Long Handed Inserter
Posts: 59
Joined: Tue Aug 12, 2014 3:47 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by cpw »

Hi there
I found a bug last night, when I was trying to add support for bob's new turrets (0.11).

I used the remote call:

Code: Select all

/c remote.call("af","insertset","","bob-gun-turret-2",{priority=1,group="turrets",limits={20},"ammo-bullets"})
The call would fail for two reasons.
First: "attempt to call global 'isValidSet' (a nil value) - this is because you've named the method incorrectly - it's defined as "isInvalidSet" but called as "isValidSet". I renamed the method to "isValidSet" since that seemed to make more sense.
Second: I got a "nil" error, when it was trying to convert the "ammo-bullets" string value to the set "ammo.bullets". It looks like you're missing "break" commands to get you out of the "j" loop in that method. To be honest, I was slightly confused about what the intended flow was there, but adding breaks to all the elseif clauses seemed to fix it.

After applying both these fixes, the command above executes successfully, and you autofill bob's gun turrets, which is nice!

Here's a diff from the 1.3.2 baseline. Hope it helps!

Code: Select all

--- a/control.lua
+++ b/control.lua
@@ -237,7 +237,7 @@
   return false
 end
 
-function isInvalidSet(set)
+function isValidSet(set)
   if set == nil then return true end
 
   local array
@@ -248,12 +248,16 @@
         return false
       elseif set[i] == "fuels-all" then
         set[i] = util.table.deepcopy(fuels.all)
+        break
       elseif set[i] == "fuels-high" then
         set[i] = util.table.deepcopy(fuels.high)
+        break
       elseif set[i] == "ammo-bullets" then
         set[i] = util.table.deepcopy(ammo.bullets)
+        break
       elseif set[i] == "ammo-shells" then
         set[i] = util.table.deepcopy(ammo.shells)
+        break
       end
     end
   end

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.12.x] Autofill

Post by rk84 »

cpw wrote:The call would fail for two reasons.
First: "attempt to call global 'isValidSet' (a nil value) - this is because you've named the method incorrectly - it's defined as "isInvalidSet" but called as "isValidSet". I renamed the method to "isValidSet" since that seemed to make more sense.
Second: I got a "nil" error, when it was trying to convert the "ammo-bullets" string value to the set "ammo.bullets". It looks like you're missing "break" commands to get you out of the "j" loop in that method. To be honest, I was slightly confused about what the intended flow was there, but adding breaks to all the elseif clauses seemed to fix it.

After applying both these fixes, the command above executes successfully, and you autofill bob's gun turrets, which is nice!
Thanks. Nice to see it been used eventhough I have miss the bug. Im not even sure myself, what have I been thinking. Inner loop were iterating input strings :? :lol: so I moved string input checks before inner loop.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

mololabo
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Aug 13, 2015 6:35 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by mololabo »

Heya!

I've been playing factorio for a while and enjoyed your (awesome) mod for some time yesterday. However, today I can't place anything needing electricity, telling me that it finds a problem (nil value) in the following line 37 of your control.lua:

if global.settings[player.name].active then

According to my research it can't find the player.name. Buuut take that with a pinch of salt.

I am using factorio 0.12.3 and I honestly do not know what the reason for that could be. I might've messed something up with my mod usage? Happens with every item I've tried so far.

Also, I am a (Java) programmer myself, so if I can supply you with any additional information, I'd be happy to help. :)

Edit: The bug surfaced only today, yesterday everything worked just fine

Edit2: Nevermind, it disappeared after uninstalling it, starting the game, loading, saving, installing the mod again. And now it works. sorry! :)

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by jorgenRe »

RK84
You may wanna move your mod to 0.12 mod place in the helper category ;)!
https://forums.factorio.com/forum/vie ... 89&t=13987
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.12.x] Autofill

Post by rk84 »

mololabo wrote:Edit2: Nevermind, it disappeared after uninstalling it, starting the game, loading, saving, installing the mod again. And now it works. sorry! :)
ah another of those compatibility issues I create in every release. Nice to see you got it solved.
jorgenRe wrote:RK84
You may wanna move your mod to 0.12 mod place in the helper category ;)!
https://forums.factorio.com/forum/vie ... 89&t=13987
oh yea. Thanks
EDIT: It seems some one has already reported the first post :?
mayby I report some other post then.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by ssilk »

Moved.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

jacobfq
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Aug 19, 2015 10:24 am
Contact:

Re: [MOD 0.12.x] Autofill

Post by jacobfq »

Hi. Firstly let me say that i love your mod. I am using Bobs Mods so i used the command to add the bob-gun-turret-2 and it works great. But when i place a turret while in my car i get an error. This is because you are trying to use game.getlocalisedentityname(..) but the function is actually called game.get_localised_entity_name(..) - Just a heads up for the next version

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.12.x] Autofill

Post by rk84 »

jacobfq wrote:Hi. Firstly let me say that i love your mod. I am using Bobs Mods so i used the command to add the bob-gun-turret-2 and it works great. But when i place a turret while in my car i get an error. This is because you are trying to use game.getlocalisedentityname(..) but the function is actually called game.get_localised_entity_name(..) - Just a heads up for the next version
Thank you.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

goblinm
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed Mar 25, 2015 3:27 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by goblinm »

db48x wrote: On a subject, I've found that autoloading turrets changes the game balance quite dramatically. Taking out even a quite large base becomes a simple matter of dropping turrets as you run by. Turrets have a lot higher dps than a distractor capsule, are manufactured more cheaply and quickly, and are available earlier in the tech tree; this makes them superior in almost all cases. I haven't tried this against massed big worms though; the larger deployment distance of a distractor capsule may be the deciding factor there.

As a solution, I suggest making it take time to construct a loaded turret. I think it would be ideal if it behaved the same way as deconstructing items; a delay during which you can't otherwise act (although on second thought I believe that you can still fire you own weapons while deconstructing things) with a little progress bar to tell you that it's working. I don't think that will be simple to implement, however.
Similar to db48x, I have also found that autofill makes gun turrets imbalanced when on the offensive. Perhaps it'd be a simple matter to detect a biter base in the immediate location around the constructing entity and pop up an error message saying, "There's no time to load the turret in the heat of battle!" when a base/worm is within X units?

Or, if that is not possible through lua, maybe have the autofill only work while the player has full health/shield. "Cannot load while injured!" It's not as concrete on locking down the imbalance, but it definitely makes the strategy less appealing. Unfortunately, this quashes autofill's usefulness as a personal defense.

The offensive power of autofill is only a problem if players choose to abuse it. My main interest is for thinking of ways to limit the imbalance to encourage Factorio devs to include some fashion of it into the main game! Cause, yeah, autofill is that core to my gameplay.

Ratzap
Filter Inserter
Filter Inserter
Posts: 371
Joined: Sun Aug 16, 2015 11:15 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by Ratzap »

Autofill is giving me an error with 12.5. Presumably if everyone else is having similar trouble we'll get a fix soon?

Liquid5n0w
Inserter
Inserter
Posts: 40
Joined: Thu Feb 05, 2015 4:10 pm
Contact:

Re: [MOD 0.12.x] Autofill

Post by Liquid5n0w »

I've been trying to get bobs turrets to use the Uranium bullets when dropped, but it seems it throws a lua error? Is this command correct?

Code: Select all

/c remote.call("af", "insertset", "", "bob-gun-turret-2", {priority=1,group="turrets",limits={20},"uranium-bullet-magazine"})
Also, I'm confused by the username field for single player, do I just leave it blank like above?

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.12.x] Autofill

Post by rk84 »

Ratzap wrote:Autofill is giving me an error with 12.5. Presumably if everyone else is having similar trouble we'll get a fix soon?
What does the error message say?
Liquid5n0w wrote:I've been trying to get bobs turrets to use the Uranium bullets when dropped, but it seems it throws a lua error? Is this command correct?

Code: Select all

/c remote.call("af", "insertset", "", "bob-gun-turret-2", {priority=1,group="turrets",limits={20},"uranium-bullet-magazine"})
Also, I'm confused by the username field for single player, do I just leave it blank like above?
I'm not sure about names, but insertables need to be in table/array of theirown. {"uranium-bullet-magazine"}

as for username. Yes that should work. Even nil should work in sp. it needs something to keep the order of parameters right.

I know, its not really elegant way of editing settings. Mayby someday I make gui for this mod.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Post Reply

Return to “Mods”