aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
Commit message (Collapse)AuthorAge
* Modernize lua read (part 1): C++ templating insurance (#7394)Loïc Blot2018-06-04
| | | | | | | * Modernize lua read (part 1): C++ templating assurance Implement the float reader
* Fix isNan on setYaw Lua call (#7380)Loïc Blot2018-05-31
| | | | * Fix isNan on setYaw Lua call
* Fix missing ignore textures (#7326)you2018-05-20
|
* Add screenshots to online content browserrubenwardy2018-05-20
|
* Add updating to online content browserrubenwardy2018-05-16
|
* Allow damage for attached objects, add attach/detach callbacks (#6786)SmallJoker2018-04-30
| | | * Allow right-clicking on attached LuaEntities
* MetaDataRef: Add contains() and get() (#7214)rubenwardy2018-04-30
|
* Add online content repositoryrubenwardy2018-04-19
| | | | Replaces mods and texture pack tabs with a single content tab
* Biome API / dungeons: Add biome-defined dungeon nodesParamat2018-04-07
| | | | | | | | | | Add new biome fields 'node_dungeon', 'node_dungeon_alt', 'node_dungeon_stair'. If 'node_dungeon' is not defined dungeons fall back to classic behaviour. Remove messy and imprecise dungeon material code from 'generateBiomes()'. Code deciding dungeon materials is now in 'generateDungeons()' and uses the biome at mapchunk centre for more precision. Remove hardcoded 'MG_STONE' types as long intended.
* Add player:get_meta(), deprecate player attributes (#7202)rubenwardy2018-04-06
| | | | * Add player:get_meta(), deprecate player attributes
* Biome API / cavegen: Add definable cave liquid for a biome (#7192)Paramat2018-04-05
| | | | Add 'node_cave_liquid' as a new field in biome registration. If field is absent cave liquids fall back to classic behaviour.
* Fix last clang-tidy reported problems for performance-type-promotion-in-math-fnLoic Blot2018-04-03
| | | | | | Based on https://travis-ci.org/minetest/minetest/jobs/361810382 output Also fix 2 missing copyright notices
* Fix many issues reported by clang-tidy (#7189)Loïc Blot2018-04-02
| | | | | | | | | | | * Fix many issues reported by clang-tidy We have many issues in code related to some performance to float <-> double. Clang-tidy reported it in performance-type-promotion-in-math-fn I fixed many of them. It's not ready for a promote to blocking Also fix some value which should be const-ref
* ObjectRef: Add add_velocity() (#3208)you2018-03-31
| | | | Allow changing the velocity of objects relatively to their current velocity
* Load dependencies and description from mod.confAndrew Ward2018-03-28
|
* Add reasons to on_dieplayer and on_hpchangeAndrew Ward2018-03-28
|
* Add formspec theming using prepended stringsAndrew Ward2018-03-28
|
* Mapgen: Remove unused mgv7 code and some unused biometypesParamat2018-03-26
|
* Cleanup sound manager class (#7158)Loïc Blot2018-03-24
| | | | | | | | | | * Cleanup sound manager client * Use some const refs * Use auto on iterators * Drop unused parameters * Move sound_openal.* to client folder * Move sound.cpp + OnDemandSoundFetcher to client/ folder + reorganize includes properly
* Biome API: Add 'get_biome_name(biome_id)' APIparamat2018-03-11
| | | | Change name of default biome to a more suitable lowercase 'default'.
* Spawn level: Add 'get_spawn_level(x, z)' APIparamat2018-03-10
| | | | Returns a suitable player spawn y co-ordinate for unmodified terrain.
* Biomes: Add 'min_pos'/'max_pos' xyz biome limitsparamat2018-03-09
| | | | 'y_min' and 'y_max' are still accepted for compatibility.
* Cleanup & bugfixLoic Blot2018-03-08
| | | | | | | | * ObjectRef::set_local_animation: fix wrong lua return (should push a boolean, currently returns nil) * ObjectRef::set_eye_offset: fix wrong lua return (should push a boolean, currently returns nil) * Fix various Server functions which depends on RemotePlayer objet and return true/false when player object is nil whereas it's a caller implementation error. Change those bool functions to void and add sanitize_check call instead. Current callers are always checking player object validity * Optimize Server::setClouds : use CloudParams object ref instead of attribute deserialization from structure & perform RemotePlayer::setCloudParams directly in server class like many other calls * Optimize Server::SendCloudParams: use CloudParams object ref instead of deserialized attributes
* Cleanup: drop Server::hudGetHotbarSelectedImage()Loic Blot2018-03-08
| | | | Call directly accessible RemotePlayer::getHotbarSelectedImage() from server api
* Cleanup: drop Server::hudGetHotbarImage()Loic Blot2018-03-08
| | | | Call directly accessible RemotePlayer::getHotbarImage() from server api & make it const ref
* Cleanup: drop Server::hudGetHotbarItemcount()Loic Blot2018-03-08
| | | | Call directly accessible RemotePlayer::getHotbarItemcount() from server api
* Gennotify: Add 'minetest.get_decoration_id' APIparamat2018-03-03
| | | | | | Returns the decoration ID for the provided decoration name string. For use with gennotify, to know the decoration IDs for use in 'minetest.set_gen_notify'.
* Place schematic (on vmanip): Enable use of 'place center' flagsparamat2018-02-27
| | | | | | For 'place schematic' and 'place schematic on vmanip' APIs. Fix 'place center' code to properly centre schematics. Fix some comments.
* Find nodes in area (under air): Raise volume limit and document itparamat2018-02-21
|
* Check argument types inside MetaDataRef Lua API (#7045)sfan52018-02-18
|
* Node definition manager refactor (#7016)Dániel Juhász2018-02-10
| | | | | | | | | * Rename IWritableNodeDefManager to NodeDefManager * Make INodeDefManager functions const * Use "const *NodeDefManager" instead of "*INodeDefManager" * Remove unused INodeDefManager class * Merge NodeDefManager and CNodeDefManager * Document NodeDefManager
* Add minetest.bulk_set_node call + optimize Environment::set_node call (#6958)Loïc Blot2018-01-30
| | | | | | | | | | * Add minetest.bulk_set_node call + experimental mod unittest * Optimize set_node function to prevent triple lookup on contentfeatures Do only one lookup for old, and try to merge old and new lookup if node is same than previous node * Add benchmark function + optimize vector population to have real results
* CSM: Remove screenshot APIred-0012018-01-23
| | | | | Reverted from commit 19960e26c672c6337f8c6ffbe27f2c6bca49750c (* [CSM] add screenshot api lua)
* [CSM] Add functions to create particles and particlespawners. (#6072)red-0012018-01-20
|
* [CSM] Add basic HUD manipulation. (#6067)red-0012018-01-20
| | | | | | * [CSM] Add basic HUD manipulation. Workaround for on_connect not working right now.
* Biomes: Add 'get heat', 'get humidity', 'get biome data' APIsparamat2018-01-16
| | | | | 'get biome data' returns biome id, heat and humidity. Clean up nearby lines in lua_api.txt.
* Fix buffer parameter not working in LuaPerlinNoiseMap::l_getMapSlice()Pedro Gimeno2018-01-08
|
* Fix naming conventions of noise userdatarubenwardy2018-01-07
|
* Biomes: Add vertical biome blend (#6853)Paramat2018-01-05
| | | | Add 'vertical blend' parameter to biome registration that defines how many nodes above the biome's 'y max' limit the blend will extend.
* Tool.cpp/.h, lua_api/l_util.cpp: Tidy up code and remove dead codeHybrid Dog2018-01-03
|
* Line_of_sight: Improve using VoxelLineIteratorDániel Juhász2017-12-26
| | | | | This commit rewrites line_of_sight with VoxelLineIterator. Stepsize is no longer needed, the results will be always accurate.
* Allow 'default' parameter in 'settings:get_bool' functionJordan Irwin2017-12-17
| | | | | | Default value is used when the setting key is not found in the config file. If default value is not set, 'nil' is returned. #6188
* Clearobjects: Send progress messages to terminal using actionstreamparamat2017-11-24
| | | | | Change default mode to 'quick' as 'full' can lock up a server for a long time.
* Stratum ore: Add option for a constant thickness stratumparamat2017-11-19
| | | | | Add a 'stratum thickness' integer parameter, as an alternative to providing a 2nd noise parameter for thickness variation.
* Load files from subfolders in texturepacksnumber Zero2017-11-17
| | | | Updated and rebased version of a PR by red-001
* Move files to subdirectories (#6599)Vitaliy2017-11-08
| | | | * Move files around
* Add minetest.safe_write_file() to script APIsfan52017-11-08
|
* Add sha1 to lua utils. (#6563)Rob Blanckaert2017-10-30
|
* CSM: Add a way to get current locale from CSMlisacvuk2017-10-29
|
* Allow overriding tool capabilities through itemstack metadataraymoo2017-10-29
| | | | | This makes it possible to modify the tool capabilities of individual itemstacks by calling a method on itemstack metadata references.
wa">return m_parent; } void reallocate() { delete[] data; data = new MapNode[nodecount]; for (u32 i = 0; i < nodecount; i++) data[i] = MapNode(CONTENT_IGNORE); raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_REALLOCATE); } //// //// Modification tracking methods //// void raiseModified(u32 mod, u32 reason=MOD_REASON_UNKNOWN) { if (mod > m_modified) { m_modified = mod; m_modified_reason = reason; if (m_modified >= MOD_STATE_WRITE_AT_UNLOAD) m_disk_timestamp = m_timestamp; } else if (mod == m_modified) { m_modified_reason |= reason; } } inline u32 getModified() { return m_modified; } inline u32 getModifiedReason() { return m_modified_reason; } std::string getModifiedReasonString(); inline void resetModified() { m_modified = MOD_STATE_CLEAN; m_modified_reason = 0; } //// //// Flags //// inline bool isDummy() { return (data == NULL); } inline void unDummify() { assert(isDummy()); // Pre-condition reallocate(); } // is_underground getter/setter inline bool getIsUnderground() { return is_underground; } inline void setIsUnderground(bool a_is_underground) { is_underground = a_is_underground; raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_SET_IS_UNDERGROUND); } inline void setLightingExpired(bool expired) { if (expired != m_lighting_expired){ m_lighting_expired = expired; raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_SET_LIGHTING_EXPIRED); } } inline bool getLightingExpired() { return m_lighting_expired; } inline bool isGenerated() { return m_generated; } inline void setGenerated(bool b) { if (b != m_generated) { raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_SET_GENERATED); m_generated = b; } } inline bool isValid() { if (m_lighting_expired) return false; if (data == NULL) return false; return true; } //// //// Position stuff //// inline v3s16 getPos() { return m_pos; } inline v3s16 getPosRelative() { return m_pos_relative; } inline core::aabbox3d<s16> getBox() { return core::aabbox3d<s16>(getPosRelative(), getPosRelative() + v3s16(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE) - v3s16(1,1,1)); } //// //// Regular MapNode get-setters //// inline bool isValidPosition(s16 x, s16 y, s16 z) { return data != NULL && x >= 0 && x < MAP_BLOCKSIZE && y >= 0 && y < MAP_BLOCKSIZE && z >= 0 && z < MAP_BLOCKSIZE; } inline bool isValidPosition(v3s16 p) { return isValidPosition(p.X, p.Y, p.Z); } inline MapNode getNode(s16 x, s16 y, s16 z, bool *valid_position) { *valid_position = isValidPosition(x, y, z); if (!*valid_position) return MapNode(CONTENT_IGNORE); return data[z * zstride + y * ystride + x]; } inline MapNode getNode(v3s16 p, bool *valid_position) { return getNode(p.X, p.Y, p.Z, valid_position); } inline MapNode getNodeNoEx(v3s16 p) { bool is_valid; MapNode node = getNode(p.X, p.Y, p.Z, &is_valid); return is_valid ? node : MapNode(CONTENT_IGNORE); } inline void setNode(s16 x, s16 y, s16 z, MapNode & n) { if (!isValidPosition(x, y, z)) throw InvalidPositionException(); data[z * zstride + y * ystride + x] = n; raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_SET_NODE); } inline void setNode(v3s16 p, MapNode & n) { setNode(p.X, p.Y, p.Z, n); } //// //// Non-checking variants of the above //// inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position) { *valid_position = data != NULL; if (!valid_position) return MapNode(CONTENT_IGNORE); return data[z * zstride + y * ystride + x]; } inline MapNode getNodeNoCheck(v3s16 p, bool *valid_position) { return getNodeNoCheck(p.X, p.Y, p.Z, valid_position); } inline void setNodeNoCheck(s16 x, s16 y, s16 z, MapNode & n) { if (data == NULL) throw InvalidPositionException(); data[z * zstride + y * ystride + x] = n; raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_SET_NODE_NO_CHECK); } inline void setNodeNoCheck(v3s16 p, MapNode & n) { setNodeNoCheck(p.X, p.Y, p.Z, n); } // These functions consult the parent container if the position // is not valid on this MapBlock. bool isValidPositionParent(v3s16 p); MapNode getNodeParent(v3s16 p, bool *is_valid_position = NULL); void setNodeParent(v3s16 p, MapNode & n); inline void drawbox(s16 x0, s16 y0, s16 z0, s16 w, s16 h, s16 d, MapNode node) { for (u16 z = 0; z < d; z++) for (u16 y = 0; y < h; y++) for (u16 x = 0; x < w; x++) setNode(x0 + x, y0 + y, z0 + z, node); } // See comments in mapblock.cpp bool propagateSunlight(std::set<v3s16> &light_sources, bool remove_light=false, bool *black_air_left=NULL); // Copies data to VoxelManipulator to getPosRelative() void copyTo(VoxelManipulator &dst); // Copies data from VoxelManipulator getPosRelative() void copyFrom(VoxelManipulator &dst); // Update day-night lighting difference flag. // Sets m_day_night_differs to appropriate value. // These methods don't care about neighboring blocks. void actuallyUpdateDayNightDiff(); // Call this to schedule what the previous function does to be done // when the value is actually needed. void expireDayNightDiff(); inline bool getDayNightDiff() { if (m_day_night_differs_expired) actuallyUpdateDayNightDiff(); return m_day_night_differs; } //// //// Miscellaneous stuff //// /* Tries to measure ground level. Return value: -1 = only air -2 = only ground -3 = random fail 0...MAP_BLOCKSIZE-1 = ground level */ s16 getGroundLevel(v2s16 p2d); //// //// Timestamp (see m_timestamp) //// // NOTE: BLOCK_TIMESTAMP_UNDEFINED=0xffffffff means there is no timestamp. inline void setTimestamp(u32 time) { m_timestamp = time; raiseModified(MOD_STATE_WRITE_AT_UNLOAD, MOD_REASON_SET_TIMESTAMP); } inline void setTimestampNoChangedFlag(u32 time) { m_timestamp = time; } inline u32 getTimestamp() { return m_timestamp; } inline u32 getDiskTimestamp() { return m_disk_timestamp; } //// //// Usage timer (see m_usage_timer) //// inline void resetUsageTimer() { m_usage_timer = 0; } inline void incrementUsageTimer(float dtime) { m_usage_timer += dtime; } inline float getUsageTimer() { return m_usage_timer; } //// //// Reference counting (see m_refcount) //// inline void refGrab() { m_refcount++; } inline void refDrop() { m_refcount--; } inline int refGet() { return m_refcount; } //// //// Node Timers //// inline NodeTimer getNodeTimer(v3s16 p) { return m_node_timers.get(p); } inline void removeNodeTimer(v3s16 p) { m_node_timers.remove(p); } inline void setNodeTimer(v3s16 p, NodeTimer t) { m_node_timers.set(p,t); } inline void clearNodeTimers() { m_node_timers.clear(); } //// //// Serialization /// // These don't write or read version by itself // Set disk to true for on-disk format, false for over-the-network format // Precondition: version >= SER_FMT_VER_LOWEST_WRITE void serialize(std::ostream &os, u8 version, bool disk); // If disk == true: In addition to doing other things, will add // unknown blocks from id-name mapping to wndef void deSerialize(std::istream &is, u8 version, bool disk); void serializeNetworkSpecific(std::ostream &os, u16 net_proto_version); void deSerializeNetworkSpecific(std::istream &is); private: /* Private methods */ void deSerialize_pre22(std::istream &is, u8 version, bool disk); /* Used only internally, because changes can't be tracked */ inline MapNode &getNodeRef(s16 x, s16 y, s16 z) { if (!isValidPosition(x, y, z)) throw InvalidPositionException(); return data[z * zstride + y * ystride + x]; } inline MapNode &getNodeRef(v3s16 &p) { return getNodeRef(p.X, p.Y, p.Z); } public: /* Public member variables */ #ifndef SERVER // Only on client MapBlockMesh *mesh; #endif NodeMetadataList m_node_metadata; NodeTimerList m_node_timers; StaticObjectList m_static_objects; static const u32 ystride = MAP_BLOCKSIZE; static const u32 zstride = MAP_BLOCKSIZE * MAP_BLOCKSIZE; static const u32 nodecount = MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE; private: /* Private member variables */ // NOTE: Lots of things rely on this being the Map Map *m_parent; // Position in blocks on parent v3s16 m_pos; /* This is the precalculated m_pos_relative value * This caches the value, improving performance by removing 3 s16 multiplications * at runtime on each getPosRelative call * For a 5 minutes runtime with valgrind this removes 3 * 19M s16 multiplications * The gain can be estimated in Release Build to 3 * 100M multiply operations for 5 mins */ v3s16 m_pos_relative; IGameDef *m_gamedef; /* If NULL, block is a dummy block. Dummy blocks are used for caching not-found-on-disk blocks. */ MapNode *data; /* - On the server, this is used for telling whether the block has been modified from the one on disk. - On the client, this is used for nothing. */ u32 m_modified; u32 m_modified_reason; /* When propagating sunlight and the above block doesn't exist, sunlight is assumed if this is false. In practice this is set to true if the block is completely undeground with nothing visible above the ground except caves. */ bool is_underground; /* Set to true if changes has been made that make the old lighting values wrong but the lighting hasn't been actually updated. If this is false, lighting is exactly right. If this is true, lighting might be wrong or right. */ bool m_lighting_expired; // Whether day and night lighting differs bool m_day_night_differs; bool m_day_night_differs_expired; bool m_generated; /* When block is removed from active blocks, this is set to gametime. Value BLOCK_TIMESTAMP_UNDEFINED=0xffffffff means there is no timestamp. */ u32 m_timestamp; // The on-disk (or to-be on-disk) timestamp value u32 m_disk_timestamp; /* When the block is accessed, this is set to 0. Map will unload the block when this reaches a timeout. */ float m_usage_timer; /* Reference count; currently used for determining if this block is in the list of blocks to be drawn. */ int m_refcount; }; typedef std::vector<MapBlock*> MapBlockVect; inline bool objectpos_over_limit(v3f p) { const static float map_gen_limit_bs = MYMIN(MAX_MAP_GENERATION_LIMIT, g_settings->getU16("map_generation_limit")) * BS; return (p.X < -map_gen_limit_bs || p.X > map_gen_limit_bs || p.Y < -map_gen_limit_bs || p.Y > map_gen_limit_bs || p.Z < -map_gen_limit_bs || p.Z > map_gen_limit_bs); } inline bool blockpos_over_limit(v3s16 p) { const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, g_settings->getU16("map_generation_limit")); return (p.X < -map_gen_limit / MAP_BLOCKSIZE || p.X > map_gen_limit / MAP_BLOCKSIZE || p.Y < -map_gen_limit / MAP_BLOCKSIZE || p.Y > map_gen_limit / MAP_BLOCKSIZE || p.Z < -map_gen_limit / MAP_BLOCKSIZE || p.Z > map_gen_limit / MAP_BLOCKSIZE); } /* Returns the position of the block where the node is located */ inline v3s16 getNodeBlockPos(v3s16 p) { return getContainerPos(p, MAP_BLOCKSIZE); } inline v2s16 getNodeSectorPos(v2s16 p) { return getContainerPos(p, MAP_BLOCKSIZE); } inline s16 getNodeBlockY(s16 y) { return getContainerPos(y, MAP_BLOCKSIZE); } inline void getNodeBlockPosWithOffset(const v3s16 &p, v3s16 &block, v3s16 &offset) { getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset); } inline void getNodeSectorPosWithOffset(const v2s16 &p, v2s16 &block, v2s16 &offset) { getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset); } /* Get a quick string to describe what a block actually contains */ std::string analyze_block(MapBlock *block); #endif