Page 3 of 15

Re: [MOD 0.11.x] Autofill

Posted: Tue Jun 30, 2015 6:57 pm
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).

Re: [MOD 0.11.x] Autofill

Posted: Wed Jul 01, 2015 9:51 am
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.

Re: [MOD 0.11.x] Autofill

Posted: Wed Jul 01, 2015 11:54 am
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?

Re: [MOD 0.11.x] Autofill

Posted: Wed Jul 01, 2015 12:38 pm
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.

Re: [MOD 0.11.x] Autofill

Posted: Thu Jul 02, 2015 8:49 pm
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.).

Re: [MOD 0.11.x] Autofill

Posted: Mon Jul 20, 2015 11:06 am
by d0cter
will this mod be updated to the new 0.12 version?

Re: [MOD 0.11.x] Autofill

Posted: Mon Jul 20, 2015 7:51 pm
by rk84
d0cter wrote:will this mod be updated to the new 0.12 version?
Done.

Re: [MOD 0.11.x] Autofill

Posted: Mon Jul 20, 2015 8:03 pm
by d0cter
rk84 wrote:
d0cter wrote:will this mod be updated to the new 0.12 version?
Done.
Great! tnx

Re: [MOD 0.12.x] Autofill

Posted: Tue Jul 21, 2015 5:30 pm
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

Re: [MOD 0.12.x] Autofill

Posted: Wed Jul 22, 2015 9:12 pm
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.

Re: [MOD 0.12.x] Autofill

Posted: Thu Aug 13, 2015 6:40 pm
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! :)

Re: [MOD 0.12.x] Autofill

Posted: Mon Aug 17, 2015 9:51 am
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

Re: [MOD 0.12.x] Autofill

Posted: Tue Aug 18, 2015 2:11 pm
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.

Re: [MOD 0.12.x] Autofill

Posted: Wed Aug 19, 2015 7:14 am
by ssilk
Moved.

Re: [MOD 0.12.x] Autofill

Posted: Wed Aug 19, 2015 10:29 am
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

Re: [MOD 0.12.x] Autofill

Posted: Thu Aug 20, 2015 5:56 am
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.

Re: [MOD 0.11.x] Autofill

Posted: Thu Aug 20, 2015 3:51 pm
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.

Re: [MOD 0.12.x] Autofill

Posted: Sat Aug 29, 2015 7:19 pm
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?

Re: [MOD 0.12.x] Autofill

Posted: Wed Sep 02, 2015 6:35 pm
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?

Re: [MOD 0.12.x] Autofill

Posted: Thu Sep 03, 2015 8:02 pm
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.