Moon Logic deprecated

by mk-fg

Adds Lua-programmable circuit network combinator. Based on Sandboxed LuaCombinator and LuaCombinator2 mods. Probably won't work in multiplayer games.

Content
2 years ago
1.0 - 1.1
4.97K
Circuit network

g [lua-qiz] Can i find_entities_filtered around the combinator itself?

3 years ago

Hi, sry noob question, but is there a way to get either the combinator object itself, or its surface+position to use find_entities_filtered around it?

my use case: i need to measure the ingredients inside an assembling-machine that stands next to the combinator (kinda what Inventory Sensor mod does)

(Many thanks btw, i love this mod already, at first i forbid myself to use it cause it looks way too OP, as a dev, but once you went through all the circuit logic the game has to offer, it becomes a must have to go even further)

3 years ago
(updated 3 years ago)

Thanks.
It's obviously a bit out of scope of the pure circuit inputs-outputs logic, but yeah, can easily do it by using globals that this mod uses to track these combinators.

Something like this should probably work, storing some (any) nearby assembler in var.machine:

if not (var.machine and var.machine.valid) then
  local mlc = _api.global.combinators[uid].e
  var.machine = mlc.surface.find_entities_filtered{
    position=mlc.position, radius=32, type='assembling-machine' }[1]
  -- can draw circle via LuaRendering at var.machine.position here to highlight picked one
end
if not (var.machine and var.machine.valid)
  then error('Failed to find assembler nearby') end
3 years ago
(updated 3 years ago)

which means i need to hardcode the combinator UID in the script? can't i retrieve it somehow? i mean, do you expose the UID in any way?

3 years ago
(updated 3 years ago)

do you expose the UID in any way?

Why yes, in the "uid" variable, as help doc probably mentions somewhere at the top :)

3 years ago

ok i feel dumb, of course it's the very first line xD sorry for having bothered you,
again, thank you very much :) this will rock

3 years ago

Nah, no worries, happens to me with any docs all the time as well.

New response