Skip to content

Commit

Permalink
Boats: Avoid crash if boat pos over limit
Browse files Browse the repository at this point in the history
If the boat pos is over limit, 'add entity' will not add an entity,
causing 'boat' to be nil.
  • Loading branch information
paramat committed Dec 21, 2016
1 parent 12b1541 commit 3c9d089
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mods/boats/init.lua
Expand Up @@ -233,9 +233,11 @@ minetest.register_craftitem("boats:boat", {
end
pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
boat:setyaw(placer:get_look_horizontal())
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
if boat then
boat:setyaw(placer:get_look_horizontal())
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
end
return itemstack
end,
Expand Down

0 comments on commit 3c9d089

Please sign in to comment.