Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ end
local function render_for_player(player, new_scan)

-- if they are not holding any item, return
if player.is_cursor_empty() then return end

-- get the item stack of whatever they are holding
stack = player.cursor_ghost or player.cursor_stack

if not stack.valid_for_read then return end
if player.is_cursor_empty() and not player.cursor_ghost then return end

local stack
if player.cursor_ghost then
-- if the cursor ghost is valid, name is the LuaItemPrototype
stack = player.cursor_ghost.name
elseif player.cursor_stack and player.cursor_stack.valid_for_read then
-- if the cursor stack is valid, prototype is the LuaItemPrototype
stack = player.cursor_stack.prototype
end

-- get the prototype, which is "name" for cursor_ghost for whatever reason
stack = prototypes.item[player.cursor_ghost and stack.name.name or stack.name]
if not stack then return end

-- if the item they are holding is not an underground belt or a pipe-to-ground, return
place_result = stack.place_result
Expand Down