Page 1 of 8

[MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 4:34 pm
by Kikkers
Smarter Circuitry
Pic
Info:
  • Adds a few new structures that allow for more precise manipulation and control of factory automation.
  • Name: Smarter Circuitry
  • Latest Release: v0.4.9, 25 October 2015 (facorio version at the time: 0.12.14)
  • Older Releases: Find the SHA of the specific version and replace the 'master' in the download url below with that SHA
  • Download: Github Zip package (Each new structure is its own mod, so you must extract them)
  • License: The Unlicense (Public domain http://unlicense.org)
  • Tags: Circuit network, Electric network, Logistics network
  • Author: Kikkers


This mod is the successor to Smart Circuit Systems, with some functionality removed (because of obsoletion) or merged into other structures, and of course some new bits. As before, I'm hoping eventually all objects in this mod will be replaced with equivalent vanilla ones, but that might still take a while. Note that this mod actually consists of several smaller mods for purposes of maintainability. You can pick some and omit others, because there is no cross-dependency between them, but I recommend just picking all because you're probably going to use them together (at least until vanilla replacements are here).
Long Description
Examples
Changelog
If you find any bugs, have any suggestions, or know of any other interesting uses for the mod, you can leave them in this thread.

Some specific suggestions I'm actively looking for is entity type specific behaviors (for the actuator or sensor). As I've manually added behavior for some specific types, there might be some types I forgot about.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 6:15 pm
by Darloth
Is it possible for you to add a pressure pad, please?

Emits a (configurable) signal when an entity is on top of it, otherwise doesn't.

Entities would include players, biters and cars... maybe trains? not sure if that's possible. I wouldn't care either way about trains on pressure pads (we have other sensors for trains in here, yay) but some people might.

A mechanical switch (rightclick to toggle between emitting a signal or not) would also be useful, but probably more difficult, and I have no idea how you'd configure which signal it would emit.

Edit: Oh, oh - attaching a sensor to a mining drill should emit the amount and type of expected remaining resources!

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 6:58 pm
by GopherAtl
ooh, this sounds nice, I will have to play with these a bit later on.

re: pressure plates, definitely possible, did a simple proof-of-concept last night in the console. Hopefully someone else will make them soon - Too many mod ideas, not enough time XD - but if nobody beats me to it, I'll make my own eventually. Smart Mining Drill is definitely also doable and a good idea, I will add that to my candidate list as well if Kikkers' (or anyone else) doesn't do it first.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 7:41 pm
by Kikkers
Darloth wrote:... maybe trains?
Trains in motion can already be detected using the sensor btw, just place it pointing to the tracks.
Darloth wrote:A mechanical switch
Could be worth looking at the switch mod form 0.11.x, that'll probably still work with minor changes. I personally dislike its graphics, so I never used it.
Darloth wrote:Is it possible for you to add a pressure pad, please?
GopherAtl wrote:re: pressure plates, definitely possible
What size of pressure pad would be practical? Also, I think I'd prefer a perimeter sensor instead (with the same functionality), having a non-collidable entity seems cheaty to me.
Darloth wrote:Oh, oh - attaching a sensor to a mining drill should emit the amount and type of expected remaining resources!
I'm hoping there's a simple method to get this information from a mining drill type entity, as I don't feel that a piece of code that keeps track of individual pieces of ore is fun to write.

Thanks for the ideas guys. I think that the pressure pad or perimeter sensor seems like the most necessary addition, so I might look into that in the coming days.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 8:18 pm
by GopherAtl
Kikkers wrote:I'm hoping there's a simple method to get this information from a mining drill type entity, as I don't feel that a piece of code that keeps track of individual pieces of ore is fun to write.
Ooh, I didn't think that far into it, just poked one with a stick and if that info is available, I couldn't find it. Code wouldn't be too bad, though, and it wouldn't have to poll them too frequently, so shouldn't be a performance concern, either.


re: pressure plate, if you don't like it being non-collidable, just make it collide in the item layer, and occupy one tile. So you can't belt over it, or build most things over it, but you can walk/drive over it (and set it off). There's something to be said for both a pressure plate - which is visually distinct, and you know you're stepping on it - versus proximity detection, where it is less obvious. Both would have their uses.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 8:47 pm
by Kikkers
GopherAtl wrote:Ooh, I didn't think that far into it, just poked one with a stick and if that info is available, I couldn't find it. Code wouldn't be too bad, though, and it wouldn't have to poll them too frequently, so shouldn't be a performance concern, either.
Any idea if it's possible then to get the mining area used by the drill? Isn't that stored in the entity prototype?

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Thu Aug 13, 2015 9:00 pm
by GopherAtl
hmm. Probably not; easy enough to just guess with vanilla, though. If you were thinking of making a sensor object placed by the mine, you'd have to support any other mods' mines specifically. I was picturing it being a "smart mining drill" object that was directly circuit-connectable, which would also require specific support for other mods' drills, but that would kind of go without saying in that case.

:edit: I was derping there, just remembered, yes, you absolutely can access prototypes at run-time, some of my utility console functions do it. So a sensor-object version could pull the area from anything, if the area is indeed in the prototype (and if it's not, it's probably hard-coded and you can assume burner mine = 2x2, electric=5x5)

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Fri Aug 14, 2015 3:13 am
by therapist
THANK YOU!!!!!!!!!!

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Fri Aug 14, 2015 1:48 pm
by Kikkers
There, we have a pressure plate. Hopefully it doesn't produce critical bugs, but we'll see. Keep your autosave engaged just in case.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Fri Aug 14, 2015 5:58 pm
by Darloth
Thankyou!

That said, it doesn't seem to be in the linked zip, and I can't see it in your github repo anywhere. I'm assuming it's going to be its own micromod like the others, or in sensor, but I can't find it.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Fri Aug 14, 2015 9:08 pm
by Kikkers
Derp, forgot to push.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sat Aug 15, 2015 12:18 pm
by Darloth
Actuator in the folder 4.2 has the info saying it's 4.0

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sat Aug 15, 2015 12:22 pm
by Kikkers
I messed up again. It -should- work now...

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sun Aug 16, 2015 1:02 pm
by Kikkers
GopherAtl wrote:hmm. Probably not; easy enough to just guess with vanilla, though. If you were thinking of making a sensor object placed by the mine, you'd have to support any other mods' mines specifically. I was picturing it being a "smart mining drill" object that was directly circuit-connectable, which would also require specific support for other mods' drills, but that would kind of go without saying in that case.

:edit: I was derping there, just remembered, yes, you absolutely can access prototypes at run-time, some of my utility console functions do it. So a sensor-object version could pull the area from anything, if the area is indeed in the prototype (and if it's not, it's probably hard-coded and you can assume burner mine = 2x2, electric=5x5)
I looked into this a bit. It seems that entity prototypes at runtime don't have all the information available that you can find in the prototype lua files. The value we would need for mining drills is the 'resource_searching_radius' field, which does not seem to be available at runtime. If that's the case, it's not currently possible to fetch remaining resources in the way that I would prefer (without hardcoding per specific mining drill object, including those added by other mods).

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sun Aug 16, 2015 1:14 pm
by SirRichie
I have not tried this and do not know of the top of my head if this is possible, but here is an idea:

in data.lua (or its variants), you can walk through all mini drills and there you have access to the mining radius. You could build a lookup table there, which you store in a global variable (not sure if you have access to global in data.lua).
You could then use this lookup table in the control.lua part.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sun Aug 16, 2015 1:17 pm
by Choumiko
Kikkers wrote:I looked into this a bit. It seems that entity prototypes at runtime don't have all the information available that you can find in the prototype lua files. The value we would need for mining drills is the 'resource_searching_radius' field, which does not seem to be available at runtime. If that's the case, it's not currently possible to fetch remaining resources in the way that I would prefer (without hardcoding per specific mining drill object, including those added by other mods).
You could work around that by using a data-final-fixes. Loop through all entites of type mining drill, for each one create a dummy recipe/item/technology/whatever (i believe technologies can be completely hidden ingame using .enabled = false). Set the name to that of the drill and a value that's readable at runtime to the searching radius. Ugly but it could work?

Edit: nearly ninja'd
SirRichie wrote:which you store in a global variable (not sure if you have access to global in data.lua)
There's no global in data.lua

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Sun Aug 16, 2015 7:52 pm
by Kikkers
Thanks for the ideas, this actually seems to work. I've added them to 4.4

The final solution was to store the resource_searching_radius in a dummy technology's time cost, which is actually accessible through a force's technology list as the research_unit_unergy field (multiplied by 60 due to ticks).

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Mon Aug 17, 2015 1:12 pm
by aklesey1
How to use pressure floor? and how to remove it?

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Mon Aug 17, 2015 4:56 pm
by Kikkers
aklesey1 wrote:How to use pressure floor? and how to remove it?
Did you have trouble under standing the "long description" in the top post? I might need to make that a bit clearer if you do.

Re: [MOD 0.12.x] Smarter Circuitry

Posted: Mon Aug 17, 2015 5:01 pm
by billw
Hey if this can detect number of robots in a roboport then it solves the issue of resupplying a limited number of construction bots to outposts and you are my hero.
I'm going to test tonight and report back, but if it doesn't then consider this a suggestion!