A. I create a dummy player entity:
Code: Select all
local s_bpr = game.get_surface("blueprinter") -- after creating the other surface of course
player.force.chart(s_bpr, {{-40,-40}, {40,40}}) -- chart the new surface to try and get the next line to work
local l_pos = s_bpr.find_non_colliding_position("player", {0,0}, 40, 1) or {player.index,player.index} -- ...nevermind, this POS has never worked; just use a default pos
local p_bpr = s_bpr.create_entity({name="player", position=l_pos, force=player.force})
global.blueprinter.inventory[player.index] = p_bpr -- using player.index because player.name is not consistent between the events
Code: Select all
local l_inventory = global.blueprinter.inventory[ l_player.index ].get_inventory( defines.inventory.player_main )
local s_stack = l_player.cursor_stack
if s_stack and s_stack.valid_for_read then
if s_stack.type == "blueprint" and s_stack.is_blueprint_setup() then
-- Insert
l_inventory.insert(s_stack)
...
s_stack.clear()
...
Code: Select all
local l_inventory = global.blueprinter.inventory[ l_player.index ].get_inventory( defines.inventory.player_main ) -- same code from above
...
-- Get target-element table index
local l_si = nil
for xi, xv in ipairs(e_registry.children_names) do
if e_schematic.name == xv then -- ...is there a better way to get the GUI elements child index, other than matching?
l_si = xi
end
end
-- GUI selection toggle; i.e. if already selected
if l_si == global.blueprinter.selected then
global.blueprinter.selected = nil
if l_inventory[l_si] and l_inventory[l_si].valid_for_read then
-- set to the players cursor_stack
s_stack.set_stack(l_inventory[l_si]) -- ...am I misreading it, or does this actually work opposite from the way the documentation describes?
end
Ok, I know everyone is probably going to focus on the part about creating zombie players on other worlds and storing stuff in their inventories ...but, I'm ok with that; I just need to know why my blueprints are getting washed. Every other item I've tried seems to go in and come out just fine; it's just the blueprints getting corpsified.