aboutsummaryrefslogtreecommitdiff
path: root/doc
Commit message (Collapse)AuthorAge
* Clarify key_value_swap's edge case (#10799)Graham Northup2021-01-29
| | | | | In compiler design especially, leaving behavior as "undefined" is a _strong_ condition that basically states that all possible integrity is violated; it's the kind of thing that happens when, say, dereferencing a pointer with unknown provenance, and most typically leads to a crash, but can result in all sorts of spectacular errors--thus, "it is undefined" how your program will melt down. The pure-Lua implementation of `key_value_swap` does not permit UB _per se_ (assuming the implementation of Lua itself is sound), but does deterministically choose the value to which a key is mapped (the last in visitation order wins--since visitation order is arbitrary, _some_ value _will_ be chosen). Most importantly, the program won't do something wildly unexpected.
* Consistently use "health points" (#10868)Zughy2021-01-27
|
* FormSpec: Add list spacing, slot size, and noclip (#10083)Vincent Robinson2021-01-23
| | | | | | | | | * Add list spacing, slot size, and noclip * Simplify StyleSpec * Add test cases Co-authored-by: rubenwardy <rw@rubenwardy.com>
* Use JSON for favorites, move server list code to Lua (#10085)rubenwardy2021-01-22
| | | Co-authored-by: sfan5 <sfan5@live.de>
* Removed some obsolete code (#10562)Zughy2021-01-21
| | | Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
* ObjectRef: fix some v3f checks (#10602)Zughy2021-01-21
|
* Fix double word "true" in minetest.is_nan explanation (#10820)M.K2021-01-18
|
* Document how to make nametags background disappear on players' head (#10783)Zughy2021-01-11
| | | Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
* Implement on_rightclickplayer callback (#10775)JDiaz2021-01-11
| | | Co-authored-by: rubenwardy <rw@rubenwardy.com>
* ContentDB: Add overwrite dialog when content is already installed (#10768)rubenwardy2021-01-04
|
* Add on_deactivate callback for luaentities (#10723)hecks2021-01-02
|
* Clarify documentation of minetest.get_modpath and minetest.get_modnames (#10771)OgelGames2021-01-02
|
* Add minetest.get_objects_in_area (#10668)Elias Fleckenstein2020-12-29
|
* Add open user data button to main menu (#10579)rubenwardy2020-12-19
|
* Documentation for highest formspec_version[] and changelog (#10592)DS2020-12-18
|
* Formspec: Allow to specify frame loop for model[] (#10679)Thomas--S2020-12-15
| | | Add the ability to specify an animation frame loop range for the model[] formspec element.
* lua_api.txt: Add mod_orgin to node def (#10697)wsor40352020-12-15
|
* Various documentation fixes (#10692)SmallJoker2020-12-10
| | | | | | | set_sky: New feature, keep note about the old syntax get_us_time: Document overflow localplayer: Document "nil" behaviour before initialization collision_box: Safe limit of "1.45"
* Cross-reference the node level manipulation functions (#10633)Oblomov2020-12-04
| | | This can help developers find the correct functions to access and manipulate the fluid level.
* Add sound to press event of some formspecs elements (#10402)Pierre-Yves Rollo2020-11-23
|
* Do not set a default for description in itemdef table (#10559)DS2020-11-10
| | | | | * Do not set a default for description in itemdef table * improve documentation
* Fix object interaction distance not being checked (#10547)rubenwardy2020-11-09
|
* Add model[] formspec element (#10320)SmallJoker2020-11-04
| | | | | | Formspec element to display models, written by @kilbith, rebased and tweaked. Co-authored-by: Jean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com> Co-authored-by: sfan5 <sfan5@live.de>
* Clean up l_object.cpp (#10512)Zughy2020-10-22
| | | Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
* Decouple entity minimap markers from nametags replacing with show_on_minimap ↵sfan52020-10-19
| | | | property (#10443)
* Remove all bump mapping and parallax occlusion related code.Lars2020-10-17
|
* Add ObjectRef:get_children() (#10480)Zughy2020-10-13
| | | Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
* Add a short_description to be used by mods (#8980)DS2020-10-09
|
* Mention texture modifier colorspace (#10112)HybridDog2020-10-08
|
* Add minetest.get_artificial_light and minetest.get_natural_light (#5680)HybridDog2020-10-06
| | | | | Add more detailed light detection functions, a function to get the artificial light (torches) and a function to get the sunlight as seen by the player (you can specify timeofday). Co-authored-by: rubenwardy <rw@rubenwardy.com>
* Minimap as HUD element with API controlPierre-Yves Rollo2020-10-04
| | | | | | | Features: * Define Minimap available modes (surface/radar, scale) from Lua, using player:set_minimap_modes() * New HUD elements for displaying minimap with custom size and placing * New minimap mode for displaying a texture instead of the map
* Add First Person Attachments (#10360)Jordan Snelling2020-10-04
| | | | | | Fixes some other third person camera specific attachments. Implements a single new flag for entities to be forced visible in first person mode. Old mods do not need to be updated to use the new flag and are fully backwards compatible.
* Deprecate get_player_velocity and add_player_velocity (#10173)rubenwardy2020-10-04
|
* Document builtin entities (#9453)Wuzzy2020-10-03
| | | This PR adds a new text file doc/builtin_entities.txt which explains how the two builtin entities __builtin:item and __builtin:falling_node work.
* Add note to docs on how to override privileges (#9792)LoneWolfHT2020-10-03
|
* Lua API: Add register_on_chatcommand to SSM and CSM (#7862)Elijah Duffy2020-10-03
| | | | | | | Allows catching a chatcommand call just after the command and the parameters are parsed but before its existence is checked and before the corresponding function is run. Returning `true` from a callback function will prevent default handling of the command leaving mods to handle the command manually.
* Chatcommand: Show help message if func returns false without messageHybridDog2020-10-03
| | | #9440
* Ability to remove minetest.after once set (#10103)tenplus12020-09-23
|
* lua_api.txt: author, release and title fields when downloading from ↵Zughy2020-09-16
| | | | | | ContentDB (#10129) Co-authored-by: Marco <4279489-marco_a@users.noreply.gitlab.com> Co-authored-by: rubenwardy <rw@rubenwardy.com>
* Fix inventory swapping not calling all callbacks (#9923)Lars Müller2020-09-04
| | | | | "Predicts" whether something will be swapped for allow callbacks, then calls callbacks a second time with swapped properties. Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
* Mark multiply and divide with two vectors as deprecated (Schur product and ↵DS2020-09-01
| | | | quotient) (#10329)
* Fix dropped craftitems/tools not using light_source values (#9438)LoneWolfHT2020-08-30
|
* Add compass HUD element (#9312)EvidenceB2020-08-29
| | | | | | Co-authored-by: Jean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com> Co-authored-by: Pierre-Yves Rollo <dev@pyrollo.com> Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
* Document normalmap textures (#10096)HybridDog2020-08-29
|
* Add vector.offset (#10321)DS2020-08-29
|
* Improve set_texture_mod documentation (#10339)karamel592020-08-27
| | | Properly documents the select_x_by_camera values
* Load media from subfolders (#9065)DS2020-08-20
|
* Add gradients and borders to FormSpec boxes (#8676)v-rob2020-08-19
|
* Clean up sound_fade (#10119)hecks2020-08-19
| | | | | Add proper documentation and correct gain reduction calculations. Co-authored-by: hecktest <>
* Allow binding dig, place actions to keys; remove LMB/RMB hardcodingANAND2020-08-15
| | | | Co-authored-by: Sam Caulfield <sam@samcaulfield.com>
X, b.X), MYMIN(a.Y, b.Y), MYMIN(a.Z, b.Z)); } inline v3s16 componentwise_max(const v3s16 &a, const v3s16 &b) { return v3s16(MYMAX(a.X, b.X), MYMAX(a.Y, b.Y), MYMAX(a.Z, b.Z)); } /** Returns \p f wrapped to the range [-360, 360] * * See test.cpp for example cases. * * \note This is also used in cases where degrees wrapped to the range [0, 360] * is innapropriate (e.g. pitch needs negative values) * * \internal functionally equivalent -- although precision may vary slightly -- * to fmodf((f), 360.0f) however empirical tests indicate that this approach is * faster. */ inline float modulo360f(float f) { int sign; int whole; float fraction; if (f < 0) { f = -f; sign = -1; } else { sign = 1; } whole = f; fraction = f - whole; whole %= 360; return sign * (whole + fraction); } /** Returns \p f wrapped to the range [0, 360] */ inline float wrapDegrees_0_360(float f) { float value = modulo360f(f); return value < 0 ? value + 360 : value; } /** Returns \p v3f wrapped to the range [0, 360] */ inline v3f wrapDegrees_0_360_v3f(v3f v) { v3f value_v3f; value_v3f.X = modulo360f(v.X); value_v3f.Y = modulo360f(v.Y); value_v3f.Z = modulo360f(v.Z); // Now that values are wrapped, use to get values for certain ranges value_v3f.X = value_v3f.X < 0 ? value_v3f.X + 360 : value_v3f.X; value_v3f.Y = value_v3f.Y < 0 ? value_v3f.Y + 360 : value_v3f.Y; value_v3f.Z = value_v3f.Z < 0 ? value_v3f.Z + 360 : value_v3f.Z; return value_v3f; } /** Returns \p f wrapped to the range [-180, 180] */ inline float wrapDegrees_180(float f) { float value = modulo360f(f + 180); if (value < 0) value += 360; return value - 180; } /* Pseudo-random (VC++ rand() sucks) */ #define MYRAND_RANGE 0xffffffff u32 myrand(); void mysrand(unsigned int seed); void myrand_bytes(void *out, size_t len); int myrand_range(int min, int max); /* Miscellaneous functions */ inline u32 get_bits(u32 x, u32 pos, u32 len) { u32 mask = (1 << len) - 1; return (x >> pos) & mask; } inline void set_bits(u32 *x, u32 pos, u32 len, u32 val) { u32 mask = (1 << len) - 1; *x &= ~(mask << pos); *x |= (val & mask) << pos; } inline u32 calc_parity(u32 v) { v ^= v >> 16; v ^= v >> 8; v ^= v >> 4; v &= 0xf; return (0x6996 >> v) & 1; } u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed); bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 camera_fov, f32 range, f32 *distance_ptr=NULL); s16 adjustDist(s16 dist, float zoom_fov); /* Returns nearest 32-bit integer for given floating point number. <cmath> and <math.h> in VC++ don't provide round(). */ inline s32 myround(f32 f) { return (s32)(f < 0.f ? (f - 0.5f) : (f + 0.5f)); } inline constexpr f32 sqr(f32 f) { return f * f; } /* Returns integer position of node in given floating point position */ inline v3s16 floatToInt(v3f p, f32 d) { return v3s16( (p.X + (p.X > 0 ? d / 2 : -d / 2)) / d, (p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d, (p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d); } /* Returns integer position of node in given double precision position */ inline v3s16 doubleToInt(v3d p, double d) { return v3s16( (p.X + (p.X > 0 ? d / 2 : -d / 2)) / d, (p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d, (p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d); } /* Returns floating point position of node in given integer position */ inline v3f intToFloat(v3s16 p, f32 d) { return v3f( (f32)p.X * d, (f32)p.Y * d, (f32)p.Z * d ); } // Random helper. Usually d=BS inline aabb3f getNodeBox(v3s16 p, float d) { return aabb3f( (float)p.X * d - 0.5f * d, (float)p.Y * d - 0.5f * d, (float)p.Z * d - 0.5f * d, (float)p.X * d + 0.5f * d, (float)p.Y * d + 0.5f * d, (float)p.Z * d + 0.5f * d ); } class IntervalLimiter { public: IntervalLimiter() = default; /* dtime: time from last call to this method wanted_interval: interval wanted return value: true: action should be skipped false: action should be done */ bool step(float dtime, float wanted_interval) { m_accumulator += dtime; if (m_accumulator < wanted_interval) return false; m_accumulator -= wanted_interval; return true; } private: float m_accumulator = 0.0f; }; /* Splits a list into "pages". For example, the list [1,2,3,4,5] split into two pages would be [1,2,3],[4,5]. This function computes the minimum and maximum indices of a single page. length: Length of the list that should be split page: Page number, 1 <= page <= pagecount pagecount: The number of pages, >= 1 minindex: Receives the minimum index (inclusive). maxindex: Receives the maximum index (exclusive). Ensures 0 <= minindex <= maxindex <= length. */ inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex) { if (length < 1 || pagecount < 1 || page < 1 || page > pagecount) { // Special cases or invalid parameters minindex = maxindex = 0; } else if(pagecount <= length) { // Less pages than entries in the list: // Each page contains at least one entry minindex = (length * (page-1) + (pagecount-1)) / pagecount; maxindex = (length * page + (pagecount-1)) / pagecount; } else { // More pages than entries in the list: // Make sure the empty pages are at the end if (page < length) { minindex = page-1; maxindex = page; } else { minindex = 0; maxindex = 0; } } } inline float cycle_shift(float value, float by = 0, float max = 1) { if (value + by < 0) return value + by + max; if (value + by > max) return value + by - max; return value + by; } inline bool is_power_of_two(u32 n) { return n != 0 && (n & (n - 1)) == 0; } // Compute next-higher power of 2 efficiently, e.g. for power-of-2 texture sizes. // Public Domain: https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 inline u32 npot2(u32 orig) { orig--; orig |= orig >> 1; orig |= orig >> 2; orig |= orig >> 4; orig |= orig >> 8; orig |= orig >> 16; return orig + 1; } // Gradual steps towards the target value in a wrapped (circular) system // using the shorter of both ways template<typename T> inline void wrappedApproachShortest(T &current, const T target, const T stepsize, const T maximum) { T delta = target - current; if (delta < 0) delta += maximum; if (delta > stepsize && maximum - delta > stepsize) { current += (delta < maximum / 2) ? stepsize : -stepsize; if (current >= maximum) current -= maximum; } else { current = target; } } void setPitchYawRollRad(core::matrix4 &m, const v3f &rot); inline void setPitchYawRoll(core::matrix4 &m, const v3f &rot) { setPitchYawRollRad(m, rot * core::DEGTORAD64); } v3f getPitchYawRollRad(const core::matrix4 &m); inline v3f getPitchYawRoll(const core::matrix4 &m) { return getPitchYawRollRad(m) * core::RADTODEG64; } // Muliply the RGB value of a color linearly, and clamp to black/white inline irr::video::SColor multiplyColorValue(const irr::video::SColor &color, float mod) { return irr::video::SColor(color.getAlpha(), core::clamp<u32>(color.getRed() * mod, 0, 255), core::clamp<u32>(color.getGreen() * mod, 0, 255), core::clamp<u32>(color.getBlue() * mod, 0, 255)); }