[MOD 0.12.x] Autofill

Topics and discussion about specific mods
Post Reply
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

[MOD 0.12.x] Autofill

Post by rk84 » Fri Nov 01, 2013 2:09 pm

Autofill inserts fuel (like coal) to entities (like car) or ammo to turret, when player builds them. (only if player has required items inside main inventory). More details in below.

Download(s)
autofill1.jpg
Tank example.
autofill1.jpg (90.64 KiB) Viewed 82180 times
Mod's default settings:
  • Items used by mod:
    • All itemprototypes with fuelvalue (is sorted from high to low)
    • Bullets: {"piercing-bullet-magazine", "basic-bullet-magazine"}
    • Shells: {"cannon-shell"}
  • car, dielsel-locomotive and tank are loaded with fuel with highest fuelvalue. (+ tank includes ammos too)
  • Burners group: Burner mining drills, Stone furnaces, Steel furnaces, Burner inserters and Boilers work same as vehicles, but all fuel is divided to all "burners" that are in quickbar and hand.
  • Turrets group: Gun turrets are loaded with ammos (First in array first in use). Ammo is divided to all turrets in quickbar and hand.
Mod's interface calls:

Code: Select all

remote.call("af", "insertset", username, entityname, settable)
remote.call("af", "toggleUsage", username)
remote.call("af", "resetUser", "default" or "lite", username)
remote.call("af", "resetMod", ["lite"])
remote.call("af", "getDefaultSets")
remote.call("af", "setDefaultSets", table)
Example of making own autofill set:

Code: Select all

remote.call("af", "insertset", "", "car", {{"coal","raw-wood"}, "basic-bullet-magazine"}) -- Creates personal setting for car.
remote.call("af", "insertset", "", "car", 0) -- insert nothing to car. (ignores default setting)
remote.call("af", "insertset", "", "car", nil) -- reset to default setting
Priority 1 is default and uses coal first. (if priority = 2 then it uses last in array and if it is 3 then item with highest itemcount is used)
Additional keys
  • group: it will divide items between all buildable items that belong to group and are in your quickbar.
  • slots: see control.lua how tank is set up.
Autofill in Github
Last edited by rk84 on Mon Feb 29, 2016 10:09 pm, edited 18 times in total.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Nirahiel
Filter Inserter
Filter Inserter
Posts: 351
Joined: Mon Sep 23, 2013 2:18 pm
Contact:

Re: [MOD 0.7.5] Autofill

Post by Nirahiel » Fri Nov 01, 2013 4:03 pm

Awesome :D

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.7.5] Autofill

Post by FreeER » Fri Nov 01, 2013 6:13 pm

Nirahiel wrote:Awesome :D
I agree, with two comments
First: Why not create a more flexible autoLoad function instead of having one for the car and one for the turret? I suppose it really only matters if you/someone wanted to expand this later (furnaces, other car prototypes, etc.)
Second: what about alternative fuels (wood, coal coke, etc.)? :D

Anyways, thanks for an awesome mod that is truly useful :D
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

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

Re: [MOD 0.7.5] Autofill

Post by rk84 » Fri Nov 01, 2013 10:48 pm

FreeER wrote:
Nirahiel wrote:Awesome :D
I agree, with two comments
First: Why not create a more flexible autoLoad function instead of having one for the car and one for the turret? I suppose it really only matters if you/someone wanted to expand this later (furnaces, other car prototypes, etc.)
Second: what about alternative fuels (wood, coal coke, etc.)? :D

Anyways, thanks for an awesome mod that is truly useful :D
Good points. I guess its partly due mindless copy/paste. Turret loading separated from another of my mod.

I will expand the fuel loading to all car types and more fuel types. But what fuel should have higher priority? One with highest item count?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.7.5] Autofill

Post by FreeER » Fri Nov 01, 2013 11:19 pm

rk84 wrote:Good points. I guess its partly due mindless copy/paste. Turret loading separated from another of my mod.
lol It's a bad habit (that almost everyone has, including me :))
I will expand the fuel loading to all car types and more fuel types. But what fuel should have higher priority? One with highest item count?
There are only two logical ways to prioritize most things, quantity and quality (fuel/damage/health value). I do not believe there is currently a way to tell what an item's fuel value is with lua, I tried game.itemprototypes but it only seems to have name/type. which only leaves highest item count, which unfortunately means you can't use it in onload to generate a table of all the bullets either (ammo maybe, but only bullet category works with a turret). Even when it is possible (I'm sure it will be eventually) it seems more logical to me to use the most available, though you could perhaps add another line to the interface so it is possible to change it.

edit: is it possible to send a table from data.lua to control.lua? Would give access to every prototype field if possible
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

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

Re: [MOD 0.7.5] Autofill

Post by rk84 » Sat Nov 02, 2013 1:00 pm

FreeER wrote:There are only two logical ways to prioritize most things, quantity and quality (fuel/damage/health value). I do not believe there is currently a way to tell what an item's fuel value is with lua, I tried game.itemprototypes but it only seems to have name/type. which only leaves highest item count, which unfortunately means you can't use it in onload to generate a table of all the bullets either (ammo maybe, but only bullet category works with a turret). Even when it is possible (I'm sure it will be eventually) it seems more logical to me to use the most available, though you could perhaps add another line to the interface so it is possible to change it.
I having some difficulties on making flexible system. I might be over thinking this. Current status: I still have 2 functions. now autofuel and autofill. Plan is to have only one or both executed depenting on what kind item sets are stored in fillable and fuelable tables. Tables use entity name or type as key and stored values have arrays of item names (or could use item stacks). Autofill could try to insert everything given in item set. Autofuel inserts fuel of one type (max one stack or fill all slots?) depending on highest itemcount or order of array. I will extend the interface to control most of this if not all.

Example of default table values

Code: Select all

--Default fueling
local fuelable =	{
						car = {"coal","raw-wood","wood"},
						locomotive = {"coal"}
						}
local fuel_priority = "itemcount" --itemcount/array. Fuel with highest itemcount or fuel first in array is used first.

--Default filling
local stacksize = 25
local fillable = 	{ --First in array first in use.
						["ammo-turret"]={"piercing-bullet-magazine","basic-bullet-magazine"}
						}
FreeER wrote: edit: is it possible to send a table from data.lua to control.lua? Would give access to every prototype field if possible
As far as I know not from data.lua, but in control.lua I used to insert mods subfolder -path into package.path, define dataloader and then just request data. It might be better to ask/suggest additional prototype properties.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.7.5] Autofill

Post by FreeER » Sat Nov 02, 2013 3:43 pm

ok, so what's the problem? lol. Hm, thinking about it you could rewrite the autoLoad function to check the fuelable/fillable tables and then branch with an if statement (which thinking about it is pretty similar to what you had lol, onevent->autoFuel/autoFill). Hm, mainly I'd say when it is possible (or maybe request these), to use something like this, so that it is (likely) fully compatible with any other mods or future vanilla additions without updates, extra script interfaces ect.

Code: Select all

local ammo = {}
local fuel = {}
for _, item pairs(game.itemprototypes) do
  if item.fuel_value then table.insert(fuel, item.name=item.fuel_value) end
  if item.type == "ammo" and item.ammo_type.category=="bullet" then
    table.insert(ammo, {item.name=item.ammo_type.action.action_delivery.target_effects[2].damage.amount)
  end
end
table.sort(fuel)
glob.fuel=fuel --could make it glob.fuel in the first place but...
table.sort(ammo)
fillable["ammo-turret"]=ammo
could have the ammo/fuel tables have sub tables of quality and quantity sorted tables, the quantity would be updated and resorted with the players inv each time autoload is called...then it's just a matter of setting which table to use and inserting ammo.priority[1] or fuel.priority[1]

Hm, when I first saw this I tried writing two functions that were slightly more flexible, more because I needed something to distract me from what I'd been working on than anything else. Here's the modded control I'd made (I'm still using the original to be honest tho). Also, I think the best method would be a combo of the two I made up here, using fuelable and fillable tables to check if the createdentity is one we care about and then passing the entity and fuel/ammo to the autoLoad function which simply checks for items in player inv and then inserts/removes it.

P.S. maybe add burner inserters to the fuelable list :)
Attachments
modded control.zip
(1.82 KiB) Downloaded 343 times
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [MOD 0.7.5] Autofill

Post by ficolas » Sat Nov 02, 2013 8:38 pm

First: Why not create a more flexible autoLoad function instead of having one for the car and one for the turret? I suppose it really only matters if you/someone wanted to expand this later (furnaces, other car prototypes, etc.)
Do it now and dont wait or you will end with arround 500 lines of copypasted code that can be done in... 30 lines? Or so xD
*Cof onplacedentity in f-mod cof*

slpwnd
Factorio Staff
Factorio Staff
Posts: 1836
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [MOD 0.7.5] Autofill

Post by slpwnd » Sun Nov 03, 2013 10:21 am

Nice mod:) I especially like the different color of flying texts depending on the amount entered.

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

Re: [MOD 0.7.5] Autofill

Post by rk84 » Mon Nov 04, 2013 4:36 pm

Uploaded new version.
FreeER wrote:ok, so what's the problem?...
I guess my problem was, still is, different use cases I try to cover with this mod. I hope you try the new code :)
ficolas wrote:Do it now and dont wait or you will end with arround 500 lines of copypasted code that can be done in... 30 lines? Or so xD
*Cof onplacedentity in f-mod cof*
heh I'm too scared to check you code anymore :lol:
kovarex wrote:Add fuel value to item prototype in lua.
Noted.
Cool. This will be most likely used in this mod in future.
slpwnd wrote:Nice mod:) I especially like the different color of flying texts depending on the amount entered.
Thanks :)
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

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

Re: [MOD 0.7.5] Autofill

Post by rk84 » Wed Nov 06, 2013 10:16 pm

After playing with this mod some time. I think choosing item based on item count was not so great as I though. I mostly want to use only coal or coal first.

In late game, you don't notice this mod at all except when you place a car, which is nice. But it led me to think think, should I add some module sets. Like production modules in miners.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

orion420
Inserter
Inserter
Posts: 24
Joined: Fri Jun 06, 2014 12:12 am
Contact:

Re: [MOD 0.7.5] Autofill

Post by orion420 » Fri Jun 27, 2014 9:30 pm

I have a friend who swears by gun turrets he will love this mod. Thanks!!!

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 » Thu Nov 20, 2014 12:56 pm

Updated for Factorio 0.11.3
Added our new friend tank and some improvements for code.

Edit: Mod is auto-activated for each user, but setting are global for all player (assuming this mod works in mp)
Possible todo personal settings.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
Align
Fast Inserter
Fast Inserter
Posts: 214
Joined: Sun Aug 10, 2014 5:17 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by Align » Thu Nov 20, 2014 7:11 pm

Oh, I hope this functionality gets added official-like to the game, no-one should be without it!

User avatar
SuperSandro2000
Filter Inserter
Filter Inserter
Posts: 693
Joined: Sun Jan 12, 2014 3:54 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by SuperSandro2000 » Fri Nov 21, 2014 3:17 pm

I like the idea but when I want to place a train that runs on liquid fuel and I have wood on my inventory I must empty the train after the building -.-.

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 » Fri Nov 21, 2014 9:53 pm

SuperSandro2000 wrote:I like the idea but when I want to place a train that runs on liquid fuel and I have wood on my inventory I must empty the train after the building -.-.
You mean solid fuel or some custom fuel?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
SuperSandro2000
Filter Inserter
Filter Inserter
Posts: 693
Joined: Sun Jan 12, 2014 3:54 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by SuperSandro2000 » Sat Nov 22, 2014 6:10 am

yes, solid fuel is made out of liquid so liquid fuel^^

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 » Sat Nov 22, 2014 10:27 pm

You can edit what gets inserted in locomotive. Here is command that should help.

Code: Select all

remote.call("autofill", "insertset", "diesel-locomotive", {slots={3}, {"solid-fuel"}})
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
SuperSandro2000
Filter Inserter
Filter Inserter
Posts: 693
Joined: Sun Jan 12, 2014 3:54 am
Contact:

Re: [MOD 0.11.x] Autofill

Post by SuperSandro2000 » Sun Nov 23, 2014 6:07 am

to complicated

FishSandwich
Smart Inserter
Smart Inserter
Posts: 1847
Joined: Sun Feb 23, 2014 3:37 pm
Contact:

Re: [MOD 0.11.x] Autofill

Post by FishSandwich » Sun Nov 23, 2014 5:30 pm

kovarex wrote:
Align wrote:Oh, I hope this functionality gets added official-like to the game, no-one should be without it!
This is what I think as well now :)
That awesome moment where a mod is deemed worthy of being implemented into the vanilla game. :D

Post Reply

Return to “Mods”

Who is online

Users browsing this forum: L0771