Creative: Fix crash when turning on creative in-game
authorRui <rui.minetest@gmail.com>
Sat, 5 Nov 2016 02:58:13 +0000 (11:58 +0900)
committerparamat <mat.gregory@virginmedia.com>
Mon, 7 Nov 2016 14:13:10 +0000 (14:13 +0000)
mods/creative/init.lua

index 24cd673b76576d0912d8e74c65532748482e7128..d90426da0d60215e26de90e9fee04221ceb002b3 100644 (file)
@@ -173,6 +173,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
        local player_name = player:get_player_name()
        local inv = player_inventory[player_name]
 
+       -- If creative is turned on mid game
+       if not inv then
+               creative.init_creative_inventory(player)
+               creative.set_creative_formspec(player, 0)
+               return
+       end
+
        if fields.quit then
                if inv.tab_id == 1 then
                        creative.set_crafting_formspec(player)