aboutsummaryrefslogtreecommitdiff
path: root/po
Commit message (Expand)AuthorAge
* Update minetest.po (Japanese)Rui2014-11-28
* Fix Belarusian translation headerShadowNinja2014-11-19
* Fix indonesian language errorsSmallJoker2014-11-18
* Update Indonesian Languagesrifqi2014-11-18
* Fix syntax error in Japanese translationRui2014-10-23
* Add Indonesian Languagesrifqi2014-10-22
* Translated using Weblate (Japanese)Rui2014-10-22
* Update ja/minetest.poRui9142014-09-21
* Revert "Small changes to French translation (Petites modifications mineures)"Kahrl2014-09-20
* Fixed french vocabulary/grammar errorskilbith2014-09-20
* Small changes to French translation (Petites modifications mineures)mimilus2014-09-20
* Fix translation name.Selat2014-03-02
* Add Belarusian translation.Selat2014-03-02
* Translated using Weblate (Spanish)Diego Martínez2014-02-16
* Translated using Weblate (Romanian)King Artur2014-02-16
* Translated using Weblate (Portuguese)João Farias2014-02-16
* Translated using Weblate (Lithuanian)Jonas Kriaučiūnas2014-02-16
* Translated using Weblate (Italian)King Artur2014-02-16
* Translated using Weblate (German)Pilz Adam2014-02-16
* Translated using Weblate (Estonian)Jabo Babo2014-02-16
* Translated using Weblate (Dutch)b p2014-02-16
* Translated using Weblate (Russian)Сергей Голубев2014-02-16
* Translated using Weblate (German)Jabo Babo2014-02-16
* Translated using Weblate (Lithuanian)Jonas Kriaučiūnas2014-02-16
* Translated using Weblate (Russian)Ilya Zhuravlev2014-02-16
* Translated using Weblate (German)Pilz Adam2014-02-16
* Translated using Weblate (Dutch)Mitchell Ward2014-02-16
* Translated using Weblate (Czech)Jakub Vaněk2014-02-16
* Translated using Weblate (Romanian)Mitchell Ward2014-02-16
* Translated using Weblate (Chinese (China))Shen Zheyu2014-02-16
* Translated using Weblate (Portuguese (Brazil))Frederico Guimarães2014-02-16
* Translated using Weblate (French)we prefer instagib metl32014-02-16
* Translated using Weblate (German)Pilz Adam2014-02-16
* Add Lithuanian translation.Ilya Zhuravlev2013-12-11
* Run updatepo.shPilzAdam2013-11-23
* Translated using Weblate (Spanish)Pablo Lezaeta2013-11-23
* Translated using Weblate (Russian)Anton Tsyganenko2013-11-23
* Translated using Weblate (Polish)Maciej Kasatkin2013-11-23
* Translated using Weblate (Czech)Jakub Vaněk2013-11-23
* Translated using Weblate (Romanian)King Artur2013-11-23
* Translated using Weblate (Czech)Jakub Vaněk2013-11-23
* Translated using Weblate (Czech)Frantisek Simorda2013-11-23
* Translated using Weblate (Spanish)Pablo Lezaeta2013-11-23
* Translated using Weblate (Czech)Heisenberg CZE2013-11-23
* Translated using Weblate (Spanish)Pablo Lezaeta2013-11-23
* Translated using Weblate (Czech)Petr Hála2013-11-23
* Translated using Weblate (Czech)Heisenberg CZE2013-11-23
* Translated using Weblate (Czech)Heisenberg CZE2013-11-23
* Translated using Weblate (Czech)Petr Hála2013-11-23
* Translated using Weblate (Spanish)William Strealy2013-10-08
a_setfield(L, LUA_REGISTRYINDEX, "minetest_current_modname"); } }; /* ScriptApiBase */ ScriptApiBase::ScriptApiBase() { #ifdef SCRIPTAPI_LOCK_DEBUG m_locked = false; #endif m_luastack = luaL_newstate(); assert(m_luastack); // Make the ScriptApiBase* accessible to ModApiBase lua_pushlightuserdata(m_luastack, this); lua_setfield(m_luastack, LUA_REGISTRYINDEX, "scriptapi"); // If we are using LuaJIT add a C++ wrapper function to catch // exceptions thrown in Lua -> C++ calls #if USE_LUAJIT lua_pushlightuserdata(m_luastack, (void*) script_exception_wrapper); luaJIT_setmode(m_luastack, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON); lua_pop(m_luastack, 1); #endif m_server = 0; m_environment = 0; m_guiengine = 0; } ScriptApiBase::~ScriptApiBase() { lua_close(m_luastack); } bool ScriptApiBase::loadMod(const std::string &scriptpath, const std::string &modname) { ModNameStorer modnamestorer(getStack(), modname); if(!string_allowed(modname, MODNAME_ALLOWED_CHARS)){ errorstream<<"Error loading mod \""<<modname <<"\": modname does not follow naming conventions: " <<"Only chararacters [a-z0-9_] are allowed."<<std::endl; return false; } bool success = false; try{ success = loadScript(scriptpath); } catch(LuaError &e){ errorstream<<"Error loading mod \""<<modname <<"\": "<<e.what()<<std::endl; } return success; } bool ScriptApiBase::loadScript(const std::string &scriptpath) { verbosestream<<"Loading and running script from "<<scriptpath<<std::endl; lua_State *L = getStack(); lua_pushcfunction(L, script_error_handler); int errorhandler = lua_gettop(L); int ret = luaL_loadfile(L, scriptpath.c_str()) || lua_pcall(L, 0, 0, errorhandler); if(ret){ errorstream<<"========== ERROR FROM LUA ==========="<<std::endl; errorstream<<"Failed to load and run script from "<<std::endl; errorstream<<scriptpath<<":"<<std::endl; errorstream<<std::endl; errorstream<<lua_tostring(L, -1)<<std::endl; errorstream<<std::endl; errorstream<<"======= END OF ERROR FROM LUA ========"<<std::endl; lua_pop(L, 1); // Pop error message from stack lua_pop(L, 1); // Pop the error handler from stack return false; } lua_pop(L, 1); // Pop the error handler from stack return true; } void ScriptApiBase::realityCheck() { int top = lua_gettop(m_luastack); if(top >= 30){ dstream<<"Stack is over 30:"<<std::endl; stackDump(dstream); throw LuaError(m_luastack, "Stack is over 30 (reality check)"); } } void ScriptApiBase::scriptError() { throw LuaError(NULL, lua_tostring(m_luastack, -1)); } void ScriptApiBase::stackDump(std::ostream &o) { int i; int top = lua_gettop(m_luastack); for (i = 1; i <= top; i++) { /* repeat for each level */ int t = lua_type(m_luastack, i); switch (t) { case LUA_TSTRING: /* strings */ o<<"\""<<lua_tostring(m_luastack, i)<<"\""; break; case LUA_TBOOLEAN: /* booleans */ o<<(lua_toboolean(m_luastack, i) ? "true" : "false"); break; case LUA_TNUMBER: /* numbers */ { char buf[10]; snprintf(buf, 10, "%g", lua_tonumber(m_luastack, i)); o<<buf; break; } default: /* other values */ o<<lua_typename(m_luastack, t); break; } o<<" "; } o<<std::endl; } void ScriptApiBase::addObjectReference(ServerActiveObject *cobj) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_add_object_reference: id="<<cobj->getId()<<std::endl; // Create object on stack ObjectRef::create(L, cobj); // Puts ObjectRef (as userdata) on stack int object = lua_gettop(L); // Get minetest.object_refs table lua_getglobal(L, "minetest"); lua_getfield(L, -1, "object_refs"); luaL_checktype(L, -1, LUA_TTABLE); int objectstable = lua_gettop(L); // object_refs[id] = object lua_pushnumber(L, cobj->getId()); // Push id lua_pushvalue(L, object); // Copy object to top of stack lua_settable(L, objectstable); } void ScriptApiBase::removeObjectReference(ServerActiveObject *cobj) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_rm_object_reference: id="<<cobj->getId()<<std::endl; // Get minetest.object_refs table lua_getglobal(L, "minetest"); lua_getfield(L, -1, "object_refs"); luaL_checktype(L, -1, LUA_TTABLE); int objectstable = lua_gettop(L); // Get object_refs[id] lua_pushnumber(L, cobj->getId()); // Push id lua_gettable(L, objectstable); // Set object reference to NULL ObjectRef::set_null(L); lua_pop(L, 1); // pop object // Set object_refs[id] = nil lua_pushnumber(L, cobj->getId()); // Push id lua_pushnil(L); lua_settable(L, objectstable); } // Creates a new anonymous reference if cobj=NULL or id=0 void ScriptApiBase::objectrefGetOrCreate( ServerActiveObject *cobj) { lua_State *L = getStack(); if(cobj == NULL || cobj->getId() == 0){ ObjectRef::create(L, cobj); } else { objectrefGet(cobj->getId()); } } void ScriptApiBase::objectrefGet(u16 id) { lua_State *L = getStack(); // Get minetest.object_refs[i] lua_getglobal(L, "minetest"); lua_getfield(L, -1, "object_refs"); luaL_checktype(L, -1, LUA_TTABLE); lua_pushnumber(L, id); lua_gettable(L, -2); lua_remove(L, -2); // object_refs lua_remove(L, -2); // minetest }