diff --git a/data/scripts/default.lua b/data/scripts/default.lua index 22486ac5a..c525ecf1e 100644 --- a/data/scripts/default.lua +++ b/data/scripts/default.lua @@ -131,9 +131,10 @@ end print("omg lol") print("minetest dump: "..dump(minetest)) -minetest.register_object("a", "dummy string"); +minetest.register_entity("a", "dummy string"); -local TNT = minetest.new_entity { +--local TNT = minetest.new_entity { +local TNT = { -- Maybe handle gravity and collision this way? dunno physical = true, weight = 5, @@ -176,9 +177,9 @@ end print("TNT dump: "..dump(TNT)) print("Registering TNT"); -minetest.register_object("TNT", TNT) +minetest.register_entity("TNT", TNT) ---print("minetest.registered_objects: "..dump(minetest.registered_objects)) -print("minetest.registered_objects:") -serialize(minetest.registered_objects) +--print("minetest.registered_entities: "..dump(minetest.registered_entities)) +print("minetest.registered_entities:") +serialize(minetest.registered_entities) diff --git a/src/content_inventory.cpp b/src/content_inventory.cpp index 1d5c6b355..51c6f751e 100644 --- a/src/content_inventory.cpp +++ b/src/content_inventory.cpp @@ -75,6 +75,8 @@ std::string item_craft_get_image_name(const std::string &subname) return "apple.png^[forcesingle"; else if(subname == "apple_iron") return "apple_iron.png"; + else if(subname == "testobject1") // test object + return "unknown_block.png^[forcesingle"; else return "cloud.png"; // just something } @@ -92,13 +94,18 @@ ServerActiveObject* item_craft_create_object(const std::string &subname, ServerActiveObject *obj = new FireflySAO(env, pos); return obj; } + else if(subname == "testobject1") + { + ServerActiveObject *obj = new LuaEntitySAO(env, pos, "TNT", ""); + return obj; + } return NULL; } s16 item_craft_get_drop_count(const std::string &subname) { - if(subname == "rat" || subname == "firefly") + if(subname == "rat" || subname == "firefly" || subname == "testobject1") return 1; return -1; diff --git a/src/content_sao.cpp b/src/content_sao.cpp index d51e92a8c..d1303b471 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -1576,9 +1576,22 @@ std::string LuaEntitySAO::getStaticData() // name os<getLua(); + scriptapi_luaentity_deregister(L, m_id); + std::string state = scriptapi_luaentity_get_state(L, m_id); + os<getId()); // Push id + lua_pushnumber(L, id); // Push id lua_pushnil(L); lua_settable(L, objectstable); @@ -340,7 +342,7 @@ void scriptapi_luaentity_step(lua_State *L, u16 id, { realitycheck(L); assert(lua_checkstack(L, 20)); - infostream<<"scriptapi_luaentity_step: id="<getId()); // Push id + lua_pushnumber(L, id); // Push id lua_gettable(L, objectstable); // TODO: Call step function diff --git a/src/server.cpp b/src/server.cpp index 1c5d8d937..82671bf89 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -989,8 +989,14 @@ Server::Server( // Export API scriptapi_export(m_lua, this); // Load and run scripts - script_load(m_lua, (porting::path_data + DIR_DELIM + "scripts" - + DIR_DELIM + "default.lua").c_str()); + std::string defaultscript = porting::path_data + DIR_DELIM + + "scripts" + DIR_DELIM + "default.lua"; + bool success = script_load(m_lua, defaultscript.c_str()); + if(!success){ + errorstream<<"Server: Failed to load and run " + <