Add code to support raillike group names
authorNovatux <nathanael.courant@laposte.net>
Tue, 12 May 2015 09:19:52 +0000 (11:19 +0200)
committerNovatux <nathanael.courant@laposte.net>
Tue, 12 May 2015 18:48:55 +0000 (20:48 +0200)
builtin/game/misc.lua
doc/lua_api.txt

index c31df541d026977bff31ce3fee636ee3385ef4ba..a71d5d02a7a3157eb70ff149b336c4e0410c9cff 100644 (file)
@@ -112,3 +112,14 @@ function core.record_protection_violation(pos, name)
        end
 end
 
+local raillike_ids = {}
+local raillike_cur_id = 0
+function core.raillike_group(name)
+       local id = raillike_ids[name]
+       if not id then
+               raillike_cur_id = raillike_cur_id + 1
+               raillike_ids[name] = raillike_cur_id
+               id = raillike_cur_id
+       end
+       return id
+end
index 8fda137ae89abc9c6506355f5a56ee9bb56eb231..5a1d49d0338caa89b72635d3512614144348327e 100644 (file)
@@ -2190,6 +2190,10 @@ These functions return the leftover itemstack.
     * Get rating of a group of an item. (`0` means: not in group)
 * `minetest.get_node_group(name, group)`: returns a rating
     * Deprecated: An alias for the former.
+* `minetest.raillike_group(name)`: returns a rating
+    * Returns rating of the connect_to_raillike group corresponding to name
+    * If name is not yet the name of a connect_to_raillike group, a new group id
+    * is created, with that name
 * `minetest.get_content_id(name)`: returns an integer
     * Gets the internal content ID of `name`
 * `minetest.get_name_from_content_id(content_id)`: returns a string