Solved - player.is_cursor_blueprint always returns true?
Posted: Thu Oct 12, 2023 9:20 pm
So I'm probably the gazillionth person trying to read blueprints from libraries and dove into the API docs to find player.is_cursor_blueprint and player.cursor_stack.is_blueprint, which should return a true/false whether the player is holding a blueprint item.
Now I tried and tested a million variants of the following piece of code:
For some reason the output is always "Cursor is a blueprint", no matter which item I select. Now on_player_cursor_stack_changed always triggers correctly, even when picking up/putting back blueprints from the library. Next is_blueprint only returns true when picking a blueprint item from the inventory and not from the library.
Is this a known issue? And how can I read a blueprint item from the library?
Now I tried and tested a million variants of the following piece of code:
Code: Select all
script.on_event(defines.events.on_player_cursor_stack_changed, function(event)
local player = game.get_player(event.player_index)
player.print("---")
if player.cursor_stack.valid then
player.print("Stack is valid")
else
player.print("Stack is NOT valid")
end
if player.cursor_stack.valid_for_read then
player.print("Stack is valid for read")
else
player.print("Stack is NOT valid for read")
end
if player.cursor_stack.is_blueprint then
player.print("Stack is a blueprint")
else
player.print("Stack is NOT a blueprint")
end
if player.is_cursor_blueprint then
player.print("Cursor is a blueprint")
else
player.print("Cursor is NOT a blueprint")
end
end)
Is this a known issue? And how can I read a blueprint item from the library?