Hi everyone,
I'm looking for the Lua way to simulate a Shift-Click-Placement of a certain blueprint at a certain position without relying on the mouse pointer. Does anybody have an idea on how that could be achieved?
What I actually want to achieve is that a moving spidertron continuously places a selected blueprint (e.g. by finding its name in my local blueprint book) at its position in the same way I would do manually by keeping Shift+Click pressed while sitting in the spidertron. However, I would like it to do it without my attendance and without having me as a driver.
So far, I am only able to place individual tiles and entities automatically at the spidertron's position and I still have to call a calculated deconstruction area each time, which seems cumbersome as it must not overlap already placed tiles/entities from the previous position. Is there an easier way to emulate the continuous Shift-Click placement?
Every hint is much appreciated!
Lua way to Shift+Click a blueprint?
Re: Lua way to Shift+Click a blueprint?
Code: Select all
blueprint.build_blueprint{
surface = spider.surface,
force = spider.force,
position = spider.position,
force_build = true,
}
Re: Lua way to Shift+Click a blueprint?
Waoh, that looks easy. Thank you!
How do I access the blueprints though? Preferably the team blueprint book's ones (alternatively my own blueprint book's ones)?
How do I access the blueprints though? Preferably the team blueprint book's ones (alternatively my own blueprint book's ones)?
Re: Lua way to Shift+Click a blueprint?
Blueprint library has very poor mod support. You need to put the blueprint somewhere on the map. Like in the spidertron, or your character inventory, or a script inventory.
Code: Select all
local blueprint = spider.get_inventory(defines.inventory.spider_trunk).find_item_stack('blueprint')
Re: Lua way to Shift+Click a blueprint?
Many thanks for your replies!
Is there a way to hard-code a constant blueprint in Lua code? (I need some way to ensure it is the correct blueprint)
Is there a way to hard-code a constant blueprint in Lua code? (I need some way to ensure it is the correct blueprint)
Re: Lua way to Shift+Click a blueprint?
Code: Select all
if not global.my_blueprint then
global.my_blueprint = game.create_inventory(1)[1]
global.my_blueprint.import_stack("0eNpVjsEKwjAQRP9lzkHaWm3Mr0iRVhdZaLehScVQ8u8m8aKnZYZ5M7tjnDayK4uH2cH3RRzMdYfjpwxT9nywBAP2NENBhjkry8mMCiwPesPUsVcg8eyZvnwR4SbbPNKaAv+kgl1cCi+SF1JBdTgphHJj7ipr5uc5hRetrgCNrtvu0nStbo5nXcX4AYUxP6Q=")
end
Re: Lua way to Shift+Click a blueprint?
Just realized, I didn't reply. Many many thanks! Works like a charm.