Skip to content

Commit

Permalink
Remote view compat + get machine count + get factory name
Browse files Browse the repository at this point in the history
  • Loading branch information
Quezler committed Jan 13, 2024
1 parent 0eb6750 commit 2735d8c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ It falls to the player to use common sense, and to not simulate an entire SPM fa

Well as you can see my data stage mod failed due to complexity reasons, easier to let another mod do the work, i just read the finished result from the gui.

# licences
# credits

- the files under `./graphics/` and their prototype defintions are MIT licenced to MagmaMcFry (original author) and notnotmelon (fork maintainer)
- `./graphics/factory/*` and their prototype defintions are MIT licenced to MagmaMcFry (original author) and notnotmelon (fork maintainer)
- `./graphics/icon/*` and their prototype defintions are MIT licenced to MagmaMcFry (original author) and notnotmelon (fork maintainer)
- parts of the control script (e.g. the `ingredients_to_factorissimo` button style/construction) come from Therenas's MIT licenced Factory Planner mod
- the thumbnail is part of a frame from a rick and morty episode about the car battery
- the power panel above the factory archways is a sprite from among us
19 changes: 16 additions & 3 deletions mods/factoryplanner-is-exportable-to-fake-factorissimo/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ script.on_event(defines.events.on_gui_opened, function(event)

-- game.print(root.name .. ' @ ' .. event.tick)

-- log(print_gui.serpent( root ))
-- log(print_gui.serpent( root.children[2].children[1].children[1].children[2] ))
-- local factories = root.children[2].children[1].children[1].children[2].children
-- local factory_name = active_radio_button(factories).caption[3]
-- log(factory_name)

-- log(print_gui.serpent( root.children[2].children[1].children[2].children[3].children[1].children[3] ))
-- log(print_gui.path_to_tooltip(root, 'fp.timescale_tt', 'root'))

Expand Down Expand Up @@ -98,9 +102,13 @@ script.on_event(defines.events.on_gui_click, function(event)
log('byproducts: ' .. serpent.line(byproducts))
log('ingredients: ' .. serpent.line(ingredients))

-- todo: check if products can be barreled
-- todo: check if byproducts can be barreled
-- todo: check if ingredients can be unbarreled

if #ingredients == 0 then
return player.create_local_flying_text{
text = "No ingredients defined at all.",
text = "No ingredients defined at all.", -- a check whether a factory is selected "should" come first, but who has none?
create_at_cursor = true,
}
end
Expand Down Expand Up @@ -138,6 +146,7 @@ script.on_event(defines.events.on_gui_click, function(event)

local recipe_class, recipe_name = split_class_and_name(table.children[offset + columns['fp.pu_recipe']].children[2].sprite)
local machine_class, machine_name = split_class_and_name(table.children[offset + columns['fp.pu_machine']].children[1].sprite)
local machine_count = math.ceil(table.children[offset + columns['fp.pu_machine']].children[1].number)

local modules = {}
for i = 2, #table.children[offset + columns['fp.pu_machine']].children do
Expand All @@ -148,7 +157,7 @@ script.on_event(defines.events.on_gui_click, function(event)
end
end

log(serpent.line({recipe_name, machine_name, modules}))
log(serpent.line({recipe_name, machine_count .. 'x ' .. machine_name, modules}))

if #table.children[offset + columns['fp.pu_beacon']].children > 1 then -- 1 = supports beacons, 2+ = beacon and module(s) selected
return player.create_local_flying_text{
Expand All @@ -173,6 +182,10 @@ script.on_event(defines.events.on_gui_click, function(event)
}
end

local factories = root.children[2].children[1].children[1].children[2].children
local factory_name = active_radio_button(factories).caption[3]
log(factory_name)

local energy_amount = tonumber(root.children[2].children[1].children[2].children[1].children[3].children[1].tooltip[2])
local energy_prefix = root.children[2].children[1].children[2].children[1].children[3].children[1].tooltip[3][1] -- k/m/w (watt)
log(energy_amount * prefix_to_multiplier(energy_prefix)) -- /60 = number to put into electric energy interface usage (* for buffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "factoryplanner-is-exportable-to-fake-factorissimo",
"title": "Factory Planner - exportable to fake factorissimo",
"description": "Skips the building stage, just feed items into the magic box.",
"version": "0.0.12",
"version": "0.0.13",
"author": "Quezler",
"factorio_version": "1.1",
"dependencies": [
"factoryplanner"
"factoryplanner",
"(?) space-exploration"
]
}

0 comments on commit 2735d8c

Please sign in to comment.