Skip to content

Commit

Permalink
Fix bad event.player_index handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RedRafe committed Oct 20, 2024
1 parent 9582e6c commit adf2f26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion map_gen/maps/april_fools/scenario/entity-restrictions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ local function on_built(event)
entity.destroy()

local stack = event.stack or event.consumed_items.get_contents()[1] -- TODO: proper handle of consumed_items as LuaInventory
local player = game.get_player(event.player_index or 'none')
local index = event.player_index
local player = index and game.get_player(index)
local robot = event.robot
if player and player.valid and not ghost and stack.valid then
if player.can_insert(stack) then
Expand Down
2 changes: 1 addition & 1 deletion map_gen/shared/entity_placement_restriction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ local on_built_token =
}
)

local player = game.get_player(index or 'none')
local player = game.get_player(index)

-- Need to revalidate the entity since we sent it to the raised event
if entity.valid then
Expand Down

0 comments on commit adf2f26

Please sign in to comment.