aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Expand)AuthorAge
...
* more linker parametersPerttu Ahola2011-01-08
* Fixed some missing linking to librariesPerttu Ahola2011-01-08
* doc updates; CMake works reasonably well now.Perttu Ahola2011-01-08
* forgot config.h.inPerttu Ahola2011-01-08
* CMake stuff works now on linux and windows... and should be possible to make ...Perttu Ahola2011-01-08
* Made dungeons a bit rarerPerttu Ahola2011-01-08
* CMake working on Linux (not on windows)Perttu Ahola2011-01-08
* Fixed dedicated server buildPerttu Ahola2011-01-07
* Added a more flexible path system (and fixed some minor stuff)Perttu Ahola2011-01-07
* removing unused code and commentsPerttu Ahola2011-01-07
* updated main.cpp TODO commentsPerttu Ahola2011-01-07
* removed Client::isFetchingBlocksPerttu Ahola2011-01-07
* removed boost support from filesys.cpp; default to posixPerttu Ahola2011-01-07
* possibly fixed broken crack textures on some machinesPerttu Ahola2010-12-29
* tuned expired mesh updating while drawing a bitPerttu Ahola2010-12-29
* A bit longer day and a bit shorter night. Client-side.Perttu Ahola2010-12-29
* oops, forgot some test code inPerttu Ahola2010-12-27
* better debug output in segfaults and stack overflows in windowsPerttu Ahola2010-12-27
* better grass generation (integration to sunlight propagation algorithms)Perttu Ahola2010-12-26
* working goodPerttu Ahola2010-12-26
* drawing range updater update and myrand() (but not usage of it)Perttu Ahola2010-12-26
* new viewing range updater algorithmPerttu Ahola2010-12-26
* main.cpp before viewing range stuff redoingPerttu Ahola2010-12-25
* some... stuff. dunno. 8-)Perttu Ahola2010-12-25
* better cavesPerttu Ahola2010-12-25
* tinkering aroundPerttu Ahola2010-12-25
* missing filesPerttu Ahola2010-12-25
* more tinkering aroundPerttu Ahola2010-12-25
* some tinkering aroundPerttu Ahola2010-12-25
* slight map generation bugsPerttu Ahola2010-12-25
* builds on both platformsPerttu Ahola2010-12-25
* minecraft-like craftingPerttu Ahola2010-12-25
* disconnect method to connection to be used instead of just timing outPerttu Ahola2010-12-24
* ProgressBarTextureModPerttu Ahola2010-12-24
* small segfault bug fixPerttu Ahola2010-12-24
* base stuff for item->object conversionPerttu Ahola2010-12-24
* changes to handing of digging (non backwards-compatible i guess)Perttu Ahola2010-12-23
* little tinkeringPerttu Ahola2010-12-23
* work-in-progress gui system updating + some settings system updatingPerttu Ahola2010-12-23
* redoing gui stuffPerttu Ahola2010-12-23
* fixed crack animation timing in clientPerttu Ahola2010-12-23
* a mutex added to TempMods which hopefully fixes rare segfaults on clientPerttu Ahola2010-12-23
* changed default time speedPerttu Ahola2010-12-22
* added fog to playersPerttu Ahola2010-12-22
* fixed crafting bugPerttu Ahola2010-12-22
* server starting on port 0 on invalid settingsPerttu Ahola2010-12-22
* crafting system!Perttu Ahola2010-12-22
* just savin'Perttu Ahola2010-12-22
* missing filesPerttu Ahola2010-12-22
* some work-in-progressPerttu Ahola2010-12-22
">lua_gettable(L, -2); // Should be a table, which we will use as a prototype //luaL_checktype(L, -1, LUA_TTABLE); if (lua_type(L, -1) != LUA_TTABLE){ errorstream<<"LuaEntity name \""<<name<<"\" not defined"<<std::endl; return false; } int prototype_table = lua_gettop(L); //dump2(L, "prototype_table"); // Create entity object lua_newtable(L); int object = lua_gettop(L); // Set object metatable lua_pushvalue(L, prototype_table); lua_setmetatable(L, -2); // Add object reference // This should be userdata with metatable ObjectRef objectrefGet(L, id); luaL_checktype(L, -1, LUA_TUSERDATA); if (!luaL_checkudata(L, -1, "ObjectRef")) luaL_typerror(L, -1, "ObjectRef"); lua_setfield(L, -2, "object"); // core.luaentities[id] = object lua_getglobal(L, "core"); lua_getfield(L, -1, "luaentities"); luaL_checktype(L, -1, LUA_TTABLE); lua_pushnumber(L, id); // Push id lua_pushvalue(L, object); // Copy object to top of stack lua_settable(L, -3); return true; } void ScriptApiEntity::luaentity_Activate(u16 id, const std::string &staticdata, u32 dtime_s) { SCRIPTAPI_PRECHECKHEADER verbosestream << "scriptapi_luaentity_activate: id=" << id << std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // Get on_activate function lua_getfield(L, -1, "on_activate"); if (!lua_isnil(L, -1)) { luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self lua_pushlstring(L, staticdata.c_str(), staticdata.size()); lua_pushinteger(L, dtime_s); setOriginFromTable(object); PCALL_RES(lua_pcall(L, 3, 0, error_handler)); } else { lua_pop(L, 1); } lua_pop(L, 2); // Pop object and error handler } void ScriptApiEntity::luaentity_Remove(u16 id) { SCRIPTAPI_PRECHECKHEADER verbosestream << "scriptapi_luaentity_rm: id=" << id << std::endl; // Get core.luaentities table lua_getglobal(L, "core"); lua_getfield(L, -1, "luaentities"); luaL_checktype(L, -1, LUA_TTABLE); int objectstable = lua_gettop(L); // Set luaentities[id] = nil lua_pushnumber(L, id); // Push id lua_pushnil(L); lua_settable(L, objectstable); lua_pop(L, 2); // pop luaentities, core } std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_get_staticdata: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // Get get_staticdata function lua_getfield(L, -1, "get_staticdata"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop entity and get_staticdata return ""; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self setOriginFromTable(object); PCALL_RES(lua_pcall(L, 1, 1, error_handler)); lua_remove(L, object); lua_remove(L, error_handler); size_t len = 0; const char *s = lua_tolstring(L, -1, &len); lua_pop(L, 1); // Pop static data return std::string(s, len); } void ScriptApiEntity::luaentity_GetProperties(u16 id, ObjectProperties *prop) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_get_properties: id="<<id<<std::endl; // Get core.luaentities[id] luaentity_get(L, id); // Set default values that differ from ObjectProperties defaults prop->hp_max = 10; /* Read stuff */ prop->hp_max = getintfield_default(L, -1, "hp_max", 10); getboolfield(L, -1, "physical", prop->physical); getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects); getfloatfield(L, -1, "weight", prop->weight); lua_getfield(L, -1, "collisionbox"); if (lua_istable(L, -1)) prop->collisionbox = read_aabb3f(L, -1, 1.0); lua_pop(L, 1); getstringfield(L, -1, "visual", prop->visual); getstringfield(L, -1, "mesh", prop->mesh); // Deprecated: read object properties directly read_object_properties(L, -1, prop); // Read initial_properties lua_getfield(L, -1, "initial_properties"); read_object_properties(L, -1, prop); lua_pop(L, 1); } void ScriptApiEntity::luaentity_Step(u16 id, float dtime) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // State: object is at top of stack // Get step function lua_getfield(L, -1, "on_step"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_step and entity return; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self lua_pushnumber(L, dtime); // dtime setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, error_handler)); lua_pop(L, 2); // Pop object and error handler } // Calls entity:on_punch(ObjectRef puncher, time_from_last_punch, // tool_capabilities, direction) void ScriptApiEntity::luaentity_Punch(u16 id, ServerActiveObject *puncher, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L,id); int object = lua_gettop(L); // State: object is at top of stack // Get function lua_getfield(L, -1, "on_punch"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_punch and entitu return; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, puncher); // Clicker reference lua_pushnumber(L, time_from_last_punch); push_tool_capabilities(L, *toolcap); push_v3f(L, dir); setOriginFromTable(object); PCALL_RES(lua_pcall(L, 5, 0, error_handler)); lua_pop(L, 2); // Pop object and error handler } // Calls entity:on_rightclick(ObjectRef clicker) void ScriptApiEntity::luaentity_Rightclick(u16 id, ServerActiveObject *clicker) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // State: object is at top of stack // Get function lua_getfield(L, -1, "on_rightclick"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_rightclick and entity return; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, clicker); // Clicker reference setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, error_handler)); lua_pop(L, 2); // Pop object and error handler }