Page 1 of 1

Grass_1 Protection Bug...

PostPosted: Tue Apr 01, 2014 08:53
by TenPlus1
When trying to place default:grass_1 near a protection block the server shuts down... It does this every time and brings up the following error:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
09:50:28: ERROR[main]: ERROR: An unhandled exception occurred: ...e/minetest/games/minetest_game/mods/farming/init.lua:212: attempt to index local 'ret' (a nil value)
09:50:28: ERROR[main]: stack traceback:
09:50:28: ERROR[main]:     ...e/minetest/games/minetest_game/mods/farming/init.lua:212: in function <...e/minetest/games/minetest_game/mods/farming/init.lua:208>

In thread b6cea700:
/build/buildd/minetestc55-201403250546/src/main.cpp:1875: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD b3cffb40:
#0  virtual void* CurlFetchThread::Thread()
DEBUG STACK FOR THREAD b6cea700:
#0  int main(int, char**)
(Leftover data: #1  Dedicated server branch)
(Leftover data: #2  virtual void ServerMap::save(ModifiedState))
(Leftover data: #3  virtual void Database_SQLite3::saveBlock(MapBlock*))
(Leftover data: #4  void ItemStack::serialize(std::ostream&) const)
Aborted


I've had to edit the /usr/share/minetest/games/minetest_game/mods/farming/init.lua file and comment out lines 208 to 213 so it wont happen on our server...

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--    on_place = function(itemstack, placer, pointed_thing)
--        -- place a random grass node
--        local stack = ItemStack("default:grass_"..math.random(1,5))
--        local ret = minetest.item_place(stack, placer, pointed_thing)
--        return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
--    end,

PostPosted: Tue Apr 01, 2014 10:33
by Krock
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.item_place(itemstack, placer, pointed_thing)

In the protection mod must return an itemstack!

Like in MyExampleProtection_mod:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
myProtectionMod.default_item_place = minetest.item_place
function minetest.item_place(itemstack, placer, pointed_thing)
    local name = placer:get_player_name()
    if myProtectionMod.isProtected(pointed_thing.above) then
        return myProtectionMod.default_item_place(itemstack, placer, pointed_thing) --default function of item_place returns itemstack, too
    else
        minetest.chat_send_player(name, "This area is protected!")
        return itemstack --it returns itemstack
    end
end