minetest.log('action', digger:get_player_name() .. " digs "
.. node.name .. " at " .. minetest.pos_to_string(pos))
- if not minetest.setting_getbool("creative_mode") then
- local wielded = digger:get_wielded_item()
- local drops = minetest.get_node_drops(node.name, wielded:get_name())
-
- -- Wear out tool
- local tp = wielded:get_tool_capabilities()
- local dp = minetest.get_dig_params(def.groups, tp)
- wielded:add_wear(dp.wear)
- digger:set_wielded_item(wielded)
-
- -- Add dropped items to object's inventory
- if digger:get_inventory() then
- local _, dropped_item
- for _, dropped_item in ipairs(drops) do
- digger:get_inventory():add_item("main", dropped_item)
- end
+ local wielded = digger:get_wielded_item()
+ local drops = minetest.get_node_drops(node.name, wielded:get_name())
+
+ -- Wear out tool
+ local tp = wielded:get_tool_capabilities()
+ local dp = minetest.get_dig_params(def.groups, tp)
+ wielded:add_wear(dp.wear)
+ digger:set_wielded_item(wielded)
+
+ -- Add dropped items to object's inventory
+ if digger:get_inventory() then
+ local _, dropped_item
+ for _, dropped_item in ipairs(drops) do
+ digger:get_inventory():add_item("main", dropped_item)
end
end
-
+
local oldmetadata = nil
if def.after_dig_node then
oldmetadata = minetest.env:get_meta(pos):to_table()
ServerActiveObject *puncher,
float time_from_last_punch)
{
- // Directly delete item in creative mode
- if(g_settings->getBool("creative_mode") == true)
- {
- m_removed = true;
- return 0;
- }
-
// Take item into inventory
ItemStack item = createItemStack();
Inventory *inv = puncher->getInventory();
}
}
-void PlayerSAO::createCreativeInventory()
-{
- if(m_inventory != &m_player->inventory)
- delete m_inventory;
-
- m_inventory = new Inventory(m_player->inventory);
- m_inventory->clearContents();
- scriptapi_get_creative_inventory(m_env->getLua(), this);
-}
-
std::string PlayerSAO::getPropertyPacket()
{
m_prop.is_visible = (getHP() != 0);
void disconnected();
- void createCreativeInventory();
-
Player* getPlayer()
{
return m_player;
return;
}
- // Don't remove from inventory in creative mode
- if(g_settings->getBool("creative_mode") == true
- && from_inv.type == InventoryLocation::PLAYER){
- }
- else{
- // Take item from source list
- ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
-
- if(item2.count != actually_dropped_count)
- errorstream<<"Could not take dropped count of items"<<std::endl;
-
- mgr->setInventoryModified(from_inv);
- }
+ // Take item from source list
+ ItemStack item2 = list_from->takeItem(from_i, actually_dropped_count);
+
+ if(item2.count != actually_dropped_count)
+ errorstream<<"Could not take dropped count of items"<<std::endl;
+
+ mgr->setInventoryModified(from_inv);
}
infostream<<"IDropAction::apply(): dropped "
u8 light;
- // In creative mode, this is the invisible backup inventory
Inventory inventory;
u16 hp;
scriptapi_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
}
-void scriptapi_get_creative_inventory(lua_State *L, ServerActiveObject *player)
-{
- realitycheck(L);
- assert(lua_checkstack(L, 20));
- StackUnroller stack_unroller(L);
-
- Inventory *inv = player->getInventory();
- assert(inv);
-
- lua_getglobal(L, "minetest");
- lua_getfield(L, -1, "creative_inventory");
- luaL_checktype(L, -1, LUA_TTABLE);
- inventory_set_list_from_lua(inv, "main", L, -1, PLAYER_INVENTORY_SIZE);
-}
-
static void get_auth_handler(lua_State *L)
{
lua_getglobal(L, "minetest");
bool scriptapi_on_respawnplayer(lua_State *L, ServerActiveObject *player);
void scriptapi_on_joinplayer(lua_State *L, ServerActiveObject *player);
void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player);
-void scriptapi_get_creative_inventory(lua_State *L, ServerActiveObject *player);
bool scriptapi_get_auth(lua_State *L, const std::string &playername,
std::string *dst_password, std::set<std::string> *dst_privs);
void scriptapi_create_auth(lua_State *L, const std::string &playername,
// Placement was handled in lua
// Apply returned ItemStack
- if(g_settings->getBool("creative_mode") == false)
- playersao->setWieldedItem(item);
+ playersao->setWieldedItem(item);
}
// If item has node placement prediction, always send the above
item, playersao, pointed))
{
// Apply returned ItemStack
- if(g_settings->getBool("creative_mode") == false)
- playersao->setWieldedItem(item);
+ playersao->setWieldedItem(item);
}
} // action == 4
// Get a preview for crafting
ItemStack preview;
- // No crafting in creative mode
- if(g_settings->getBool("creative_mode") == false)
- getCraftingResult(&player->inventory, preview, false, this);
+ getCraftingResult(&player->inventory, preview, false, this);
// Put the new preview in
InventoryList *plist = player->inventory.getList("craftpreview");
scriptapi_on_joinplayer(m_lua, playersao);
- /* Creative mode */
- if(g_settings->getBool("creative_mode"))
- playersao->createCreativeInventory();
-
return playersao;
}