Difference between revisions of "User:Hybrid Dog"

From Minetest Developer Wiki
Jump to navigation Jump to search
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
<source>-- recently modified by beautifier.lua
+
== various ==
or string.find(node.name, "default:water_")
+
performance test shows
minetest.set_node(pos, {name="tnt:tnt_burning"})
+
<source>
end
+
local t0 = benchmark_function(function()
interval = 2,
+
for i = 1,1000 do
description = "TNT",
+
local v = math.pow(2, i)
nodes[p_pos] = tnt_c_fire
 
if not drop_items
 
local p_node = area:index(p.x, p.y, p.z)
 
if obj == nil then
 
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
 
end
 
for dy=-1,1 do
 
l = l-1
 
if puncher:get_wielded_item():get_name() == "default:torch" then
 
-- )
 
local function combine_texture(texture_size, frame_count, texture, ani_texture)
 
boom({x=p.x, y=p.y, z=p.z}, 0, player)
 
px = px+texture_size
 
 
 
sounds = default.node_sound_wood_defaults(),
 
obj:setacceleration({x=0, y=-10, z=0})
 
tiles = {"default_tnt_top.png", "default_tnt_bottom.png", tnt_side},
 
}
 
nodes[p_node] = tnt_c_tnt_burning
 
if nodename ~= "tnt:gunpowder" then
 
--minetest.set_node(pos, {name="tnt:boom"})
 
return
 
drop_items = true
 
manip:update_map()
 
end
 
-- recently modified by beautifier.lua
 
end
 
minetest.after(0.5, function(pos)
 
end
 
or (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item") then
 
else
 
destroy(p, player)
 
for dz=-1,1 do
 
output = "tnt:tnt",
 
tiles = {{name="tnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
 
pos.y = pos.y+dy
 
tnt_c_air = minetest.get_content_id("air")
 
if node.name == "tnt:tnt" then
 
light_source = 5,
 
 
 
-- recently modified by beautifier.lua
 
chance = 10,
 
end
 
burn({x=pos.x, y=pos.y, z=pos.z}, player)
 
},
 
for _,item in ipairs(drop) do
 
end, {x=pos.x, y=pos.y, z=pos.z})
 
 
 
{"", "group:wood", "" }
 
 
 
end
 
100, --amount
 
tiles = {"tnt_gunpowder.png",},
 
{x=pos.x-3, y=pos.y-3, z=pos.z-3}, --minpos
 
minetest.set_node(pos, {name="tnt:tnt_burning"})
 
pos.z = pos.z-dz
 
minetest.set_node(pos, {name="tnt:tnt_burning"})
 
minetest.add_particle(pos, {x=0,y=0,z=0}, {x=0,y=0,z=0}, 0.5, 16, false, "tnt_boom.png")
 
end
 
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
 
else
 
end
 
 
 
 
 
return
 
tiles = {{name=animated_tnt_texture, animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}},
 
-- recently modified by beautifier.lua
 
minetest.register_abm({
 
selection_box = {
 
local tnt_preserve_items = false
 
neighbors = {"fire:basic_flame"},
 
for _,obj in ipairs(objects) do
 
end
 
burn(pos)
 
enable = function(pos)
 
minetest.sound_play("tnt_ignite", {pos=pos})
 
else
 
end
 
 
 
if obj == nil then
 
return
 
"default_tnt_bottom.png", tnt_side},
 
end
 
if minetest.get_node(pos).name ~= "tnt:gunpowder_burning" then
 
if minetest.setting_get("log_mods") then
 
end
 
for dz=-tnt_range,tnt_range do
 
minetest.register_craft({
 
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
 
end
 
local function destroy(pos, player)
 
sounds = default.node_sound_leaves_defaults(),
 
 
 
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
 
action_on = function(pos, node)
 
})
 
area = VoxelArea:new{MinEdge=emerged_pos1, MaxEdge=emerged_pos2}
 
end
 
or not tnt_preserve_items then
 
})
 
if type(item) == "string" then
 
if obj:is_player()
 
damage_groups={fleshy=damage},
 
false, --collisiondetection
 
{x=0.5,y=5,z=0.5}, --maxacc
 
end
 
sounds = default.node_sound_leaves_defaults(),
 
burn(pos, puncher)
 
 
 
manip:set_data(nodes)
 
local objects = minetest.get_objects_inside_radius(pos, 7)
 
local animated_tnt_texture = combine_texture(16, 4, "default_tnt_top.png", "tnt_top_burning_animated.png")
 
minetest.register_node(":tnt:tnt", {
 
1, --maxexptime
 
 
 
while l ~= 0 do
 
end
 
local tnt_side = "default_tnt_side.png^tnt_shadows.png"
 
obj:get_luaentity().collect = true
 
description = "Gun Powder",
 
end
 
15, --maxsize
 
type = "shapeless",
 
})
 
or string.find(node.name, "default:lava_")) then
 
 
end
 
end
return
+
end)
local obj = minetest.add_item(pos, item)
 
 
 
if math.abs(dx) == 1 or math.abs(dz) == 1 then
 
},
 
drawtype = "raillike",
 
  
 +
local t1 = benchmark_function(function()
 +
local ln2 = math.log(2)
 +
for i = 1,1000 do
 +
local v = math.exp(i * ln2)
 
end
 
end
local combine_textures = ":0,"..px.."="..texture
+
end)</source>
 
+
the exp thing is faster by the factor 1.37
 
 
on_punch = function(pos, node, puncher)
 
minetest.set_node(pos, {name="tnt:tnt_burning"})
 
0.1, --time
 
end
 
end
 
local px = 0
 
obj:setvelocity({x=pr:next(0,6)-3, y=10, z=pr:next(0,6)-3})
 
local function drop_item(pos, nodename, player)
 
for i=1,item:get_count() do
 
else
 
 
 
 
 
manip:write_to_map()
 
tnt_c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
 
sunlight_propagates = true,
 
obj:setvelocity({x=pr:next(0,6)-3, y=10, z=pr:next(0,6)-3})
 
0.1, --minexptime
 
{"group:wood", "tnt:gunpowder", "group:wood"},
 
drop = "",
 
minetest.add_particlespawner(
 
return
 
nodenames = {"tnt:tnt", "tnt:gunpowder"},
 
destroy(p, player)
 
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+tnt_seed)
 
return
 
full_punch_interval=1.0,
 
groups = {dig_immediate=2,attached_node=1},
 
minetest.register_craft({
 
 
 
)
 
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
 
laser = {
 
recipe = {"default:coal_lump", "default:gravel"}
 
local t1 = os.clock()
 
local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
 
function boom(pos, time, player)
 
minetest.register_node(":tnt:gunpowder", {
 
})
 
pos.x = pos.x+dx
 
minetest.register_node(":tnt:gunpowder_burning", {
 
obj:punch(obj, 1.0, {
 
 
 
end
 
end
 
minetest.register_node(":tnt:tnt_burning", {
 
 
 
inv:add_item("main", item)
 
output = "tnt:gunpowder",
 
minetest.sound_play("tnt_ignite", {pos=pos})
 
local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
 
{x=pos.x+3, y=pos.y+3, z=pos.z+3}, --maxpos
 
if not player then
 
end
 
selection_box = {
 
nodes = manip:get_data()
 
end
 
local obj_p = obj:getpos()
 
})
 
paramtype = "light",
 
end
 
return
 
else
 
 
 
pr = get_tnt_random(pos)
 
pos.x = pos.x-dx
 
inv = player:get_inventory()
 
end,
 
 
 
})
 
end
 
end
 
end
 
effector = {
 
minetest.after(time, function(pos)
 
local emerged_pos1, emerged_pos2 = manip:read_from_map({x=pos.x-width, y=pos.y-width, z=pos.z-width},
 
local node =  minetest.get_node(p)
 
 
 
end
 
minetest.set_node(pos, {name="tnt:tnt_burning"})
 
end
 
type = "fixed",
 
if minetest.get_node(pos).name ~= "tnt:tnt_burning" then
 
on_punch = function(pos, node, puncher)
 
boom(pos, 2)
 
local tnt_range = 2
 
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
 
local manip = minetest.get_voxel_manip()
 
end
 
-- minetest.remove_node(pos)
 
drop_item(pos, nodename, player)
 
elseif not ( d_p_node == tnt_c_fire
 
if nodes[p_pos] ~= tnt_c_air then
 
-- recently modified by beautifier.lua
 
-- end, {x=pos.x, y=pos.y, z=pos.z}
 
 
 
 
 
burn({x=pos.x, y=pos.y, z=pos.z}, player)
 
local obj = minetest.add_item(pos, item:get_name())
 
 
 
minetest.after(1, function(pos)
 
 
 
-- minetest.after(0.5, function(pos)
 
end,
 
end
 
wield_image = "tnt_gunpowder_inventory.png",
 
minetest.remove_node(pos)
 
{x=0, y=0, z=0}, --maxvel
 
boom(pos, 1, player)
 
end
 
if puncher:get_wielded_item():get_name() == "default:torch" then
 
local nodename = minetest.get_node(pos).name
 
end
 
end
 
 
 
paramtype = "light",
 
pos.y = pos.y-dy
 
sounds = default.node_sound_wood_defaults(),
 
 
 
local d_p_node = nodes[p_node]
 
{"", "group:wood", "" },
 
minetest.set_node(pos, {name="tnt:gunpowder_burning"})
 
}, vec)
 
obj:get_luaentity().collect = true
 
})
 
 
 
local damage = (80*0.5^dist)*2
 
if dy == 0 then
 
"tnt_smoke.png" --texture
 
walkable = false,
 
local p_pos = area:index(pos.x, pos.y, pos.z)
 
local function get_tnt_random(pos)
 
8, --minsize
 
 
 
drawtype = "raillike",
 
groups = {dig_immediate=2, mesecon=2},
 
},
 
drop = "",
 
end
 
return
 
function burn(pos, player)
 
end, pos)
 
--minetest.register_node("tnt:boom", {drop="", groups={dig_immediate=3}})
 
boom(pos, 4, puncher)
 
if not inv then
 
 
 
local drop_items = tnt_drop_items
 
else
 
and inv:room_for_item("main", item) then
 
 
 
tnt_c_tnt = minetest.get_content_id("tnt:tnt")
 
light_source = 5,
 
end
 
local tnt_drop_items = false
 
 
 
nodes[p_pos] = tnt_c_air
 
{x=-0.5,y=5,z=-0.5}, --minacc
 
end, pos)
 
if pr:next(1,3) == 3
 
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
 
inventory_image = "tnt_gunpowder_inventory.png",
 
combine_textures = combine_textures..":0,"..px.."="..texture
 
{x=-0, y=-0, z=-0}, --minvel
 
local t1 = os.clock()
 
boom(pos, 0)
 
nodes[p_pos] = tnt_c_air
 
if pr:next(1,5) <= 4 then
 
minetest.sound_play("tnt_gunpowder_burning", {pos=pos, gain=2})
 
end
 
local width = tnt_range
 
-- nodeupdate(pos)
 
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
 
-- minetest.remove_node(pos)
 
minetest.log("action", "tnt loaded")
 
if d_p_node == tnt_c_tnt
 
sunlight_propagates = true,
 
local drop = minetest.get_node_drops(nodename)
 
end
 
if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
 
recipe = {
 
type = "fixed",
 
if nodename == "tnt:tnt" then
 
end
 
for dx=-1,1 do
 
for dx=-tnt_range,tnt_range do
 
end
 
local nodename = minetest.get_node(pos).name
 
action = function(pos, node)
 
groups = {dig_immediate=2,attached_node=1},
 
}
 
pos.z = pos.z+dz
 
{x=pos.x+width, y=pos.y+width, z=pos.z+width})
 
},
 
walkable = false,
 
minetest.sound_play("tnt_ignite", {pos=pos})
 
print(string.format("[tnt] map updated after: %.2fs", os.clock() - t1))
 
local l = frame_count
 
 
 
return ani_texture.."^[combine:"..texture_size.."x"..texture_size*frame_count..":"..combine_textures.."^"..ani_texture
 
obj:setacceleration({x=0, y=-10, z=0})
 
mesecons = {
 
for dy=tnt_range,-tnt_range,-1 do
 
drop_items = true
 
local p_pos = area:index(pos.x, pos.y, pos.z)
 
or d_p_node == tnt_c_tnt_burning then
 
if minetest.registered_nodes[nodename].groups.flammable ~= nil then
 
local tnt_seed = 15
 
</source>
 
  
 +
<br/>
 
== minetest.on_place ==
 
== minetest.on_place ==
  
Line 356: Line 23:
 
<source>minetest.on_place(nodename, func)</source>
 
<source>minetest.on_place(nodename, func)</source>
  
 +
<br/>
 
=== Description ===
 
=== Description ===
 
This changes on_place of a node after it was defined.<br/>
 
This changes on_place of a node after it was defined.<br/>
Line 370: Line 38:
 
end</source>
 
end</source>
  
 +
<br/>
 
==== nodename ====
 
==== nodename ====
 
The name of the node which should become changed
 
The name of the node which should become changed
  
 +
<br/>
 
==== func ====
 
==== func ====
 
should return true if the node becomes set
 
should return true if the node becomes set
 
<source>function(itemstack, placer, pointed_thing)</source>
 
<source>function(itemstack, placer, pointed_thing)</source>
  
 +
<br/>
 
=== Example ===
 
=== Example ===
 
<source>minetest.on_place("hydro:growlamp", function(itemstack, placer, pointed_thing)
 
<source>minetest.on_place("hydro:growlamp", function(itemstack, placer, pointed_thing)
Line 396: Line 67:
 
return true
 
return true
 
end)</source>
 
end)</source>
 +
 +
<br/>
 +
== minetest key press and release functions ==
 +
 +
 +
=== Syntax ===
 +
<source>minetest.register_on_key_press(func(player, key))</source>
 +
<source>minetest.register_on_key_release(func(player, key))</source>
 +
 +
<br/>
 +
 +
=== Description ===
 +
These functions get executed when a player presses or releases a key.<br>
 +
They're not implemented into minetest but can be added via mod(s):
 +
<source>local on_key_releases,nr = {},0
 +
function minetest.register_on_key_release(func)
 +
nr = nr+1
 +
on_key_releases[nr] = func
 +
end
 +
 +
local on_key_presses,np = {},0
 +
function minetest.register_on_key_press(func)
 +
np = np+1
 +
on_key_presses[np] = func
 +
end
 +
 +
local playerkeys = {}
 +
minetest.register_globalstep(function()
 +
for _,player in pairs(minetest.get_connected_players()) do
 +
local last_keys = playerkeys[player:get_player_name()]
 +
for key,stat in pairs(player:get_player_control()) do
 +
if stat then
 +
if not last_keys[key] then
 +
for i = 1,np do
 +
on_key_presses[i](player, key)
 +
end
 +
last_keys[key] = true
 +
end
 +
elseif last_keys[key] then
 +
for i = 1,nr do
 +
on_key_releases[i](player, key)
 +
end
 +
last_keys[key] = false
 +
end
 +
end
 +
end
 +
end)
 +
 +
minetest.register_on_joinplayer(function(player)
 +
playerkeys[player:get_player_name()] = {}
 +
end)</source>
 +
 +
 +
<br/>
 +
==== player ====
 +
The player who pressed the key
 +
 +
<br/>
 +
==== key ====
 +
A string, the released or pressed key, see the get_player_control at Player.
 +
 +
<br/>
 +
=== Examples ===
 +
<source>-- tell the player which keys he/she/it presses and releases
 +
 +
minetest.register_on_key_release(function(player, key)
 +
minetest.chat_send_player(player:get_player_name(), "you released "..key)
 +
end)
 +
 +
minetest.register_on_key_press(function(player, key)
 +
minetest.chat_send_player(player:get_player_name(), "you keydownd "..key)
 +
end)</source>
 +
 +
<br/>
  
 
== Mods ==
 
== Mods ==
Line 401: Line 146:
  
 
=== vector_extras ===
 
=== vector_extras ===
 +
 +
Note that this is very outdated. The documentation is now at [https://github.com/HybridDog/vector_extras].
  
 
Those are added as fields of the vector table, e.g. vector.pos_to_string(pos)
 
Those are added as fields of the vector table, e.g. vector.pos_to_string(pos)
Line 414: Line 161:
 
| works
 
| works
 
|-
 
|-
|<source enclose="none">line([pos, dir[, range][, alt]])</source>
+
|<source enclose="none">line([pos, dir[, range][, alt)</source>
| table of [[vector]]s
+
| table of vectors
 
| dir can be following:
 
| dir can be following:
 
* a direction
 
* a direction
* a [[position]] (range not needed)
+
* a position (range not needed)
 
if alt then the old path calculation is used
 
if alt then the old path calculation is used
 
| works
 
| works
 
|-
 
|-
 
|<source enclose="none">fine_line([pos, dir[, range], scale])</source>
 
|<source enclose="none">fine_line([pos, dir[, range], scale])</source>
| table of [[vector]]s
+
| table of vectors
 
|
 
|
 
* like the old vector.line but more precise
 
* like the old vector.line but more precise
 
* needed for not round positions
 
* needed for not round positions
* try using [[minetest.line_of_sight]] instead
+
* try using minetest.line_of_sight instead
 
| works but<br/>old and slow
 
| works but<br/>old and slow
 
|-
 
|-
Line 467: Line 214:
 
| unfinished
 
| unfinished
 
|-
 
|-
|<source enclose="none">straightdelay([s, v[, a]])</source>
+
|<source enclose="none">straightdelay([s, v[, a)</source>
 
| number
 
| number
 
|
 
|
Line 476: Line 223:
 
|-
 
|-
 
|<source enclose="none">sun_dir(t)</source>
 
|<source enclose="none">sun_dir(t)</source>
| [[vector]]
+
| vector
 
|
 
|
 
* t = timeofday
 
* t = timeofday
Line 487: Line 234:
 
|-
 
|-
 
|<source enclose="none">minmax(p1, p2)</source>
 
|<source enclose="none">minmax(p1, p2)</source>
| [[vector]], [[vector]]
+
| vector, vector
| the first [[vector]]'s x, y and z are smaller than the second one's
+
| the first vector's x, y and z are smaller than the second one's
 
| untested
 
| untested
 
|-
 
|-
 
|<source enclose="none">move(p1, p2, s)</source>
 
|<source enclose="none">move(p1, p2, s)</source>
| [[vector]]
+
| vector
 
|
 
|
 
* s = length
 
* s = length
Line 518: Line 265:
 
|-
 
|-
 
|<source enclose="none">circle(r)</source>
 
|<source enclose="none">circle(r)</source>
| table of [[vector]]s
+
| table of vectors
 
|
 
|
 
* r = radius
 
* r = radius
Line 524: Line 271:
 
|-
 
|-
 
|<source enclose="none">ring(r)</source>
 
|<source enclose="none">ring(r)</source>
| table of [[vector]]s
+
| table of vectors
 
|
 
|
 
* r = radius
 
* r = radius
Line 532: Line 279:
 
|-
 
|-
 
|<source enclose="none">chunkcorner(pos)</source>
 
|<source enclose="none">chunkcorner(pos)</source>
| [[vector]]
+
| vector
 
| should return the chunkcorner near pos
 
| should return the chunkcorner near pos
 
| could work
 
| could work
Line 580: Line 327:
 
|<source enclose="none">quickadd(pos[, z,y,x])</source>
 
|<source enclose="none">quickadd(pos[, z,y,x])</source>
 
| nil
 
| nil
| adds those to pos'
+
| adds those to pos', works more than 4.3 times as fast as using vector.add
 
| works
 
| works
 
|-
 
|-

Latest revision as of 19:45, 25 January 2023

various

performance test shows

	local t0 = benchmark_function(function()
		for i = 1,1000 do
			local v = math.pow(2, i)
		end
	end)

	local t1 = benchmark_function(function()
		local ln2 = math.log(2)
		for i = 1,1000 do
			local v = math.exp(i * ln2)
		end
	end)

the exp thing is faster by the factor 1.37


minetest.on_place

Syntax

minetest.on_place(nodename, func)


Description

This changes on_place of a node after it was defined.
It is not implemented into minetest but can be added via mod(s):

minetest.on_place = minetest.on_place or function(name, func)
	local previous_on_place = minetest.registered_nodes[name].on_place
	minetest.override_item(name, {
		on_place = function(...)
			if func(...) then
				return previous_on_place(...)
			end
		end
	})
end


nodename

The name of the node which should become changed


func

should return true if the node becomes set

function(itemstack, placer, pointed_thing)


Example

minetest.on_place("hydro:growlamp", function(itemstack, placer, pointed_thing)
	if not pointed_thing then
		return
	end
	local pos = minetest.get_pointed_thing_position(pointed_thing, true)
	if not pos then
		return
	end
	local nd_above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
	local nd_above_info = minetest.registered_nodes[nd_above]
	if nd_above == "air"
	or nd_above == "hydro:growlamp"
	or not nd_above_info.walkable
	or nd_above_info.buildable_to then
		return
	end
	return true
end)


minetest key press and release functions

Syntax

minetest.register_on_key_press(func(player, key))
minetest.register_on_key_release(func(player, key))


Description

These functions get executed when a player presses or releases a key.
They're not implemented into minetest but can be added via mod(s):

local on_key_releases,nr = {},0
function minetest.register_on_key_release(func)
	nr = nr+1
	on_key_releases[nr] = func
end

local on_key_presses,np = {},0
function minetest.register_on_key_press(func)
	np = np+1
	on_key_presses[np] = func
end

local playerkeys = {}
minetest.register_globalstep(function()
	for _,player in pairs(minetest.get_connected_players()) do
		local last_keys = playerkeys[player:get_player_name()]
		for key,stat in pairs(player:get_player_control()) do
			if stat then
				if not last_keys[key] then
					for i = 1,np do
						on_key_presses[i](player, key)
					end
					last_keys[key] = true
				end
			elseif last_keys[key] then
				for i = 1,nr do
					on_key_releases[i](player, key)
				end
				last_keys[key] = false
			end
		end
	end
end)

minetest.register_on_joinplayer(function(player)
	playerkeys[player:get_player_name()] = {}
end)



player

The player who pressed the key


key

A string, the released or pressed key, see the get_player_control at Player.


Examples

-- tell the player which keys he/she/it presses and releases

minetest.register_on_key_release(function(player, key)
	minetest.chat_send_player(player:get_player_name(), "you released "..key)
end)

minetest.register_on_key_press(function(player, key)
	minetest.chat_send_player(player:get_player_name(), "you keydownd "..key)
end)


Mods

vector_extras

Note that this is very outdated. The documentation is now at [1].

Those are added as fields of the vector table, e.g. vector.pos_to_string(pos)

Function Return value Comments Status
pos_to_string(pos) string similar to minetest.pos_to_string, but better readable in my opinion works
line([pos, dir[, range][, alt) table of vectors dir can be following:
  • a direction
  • a position (range not needed)

if alt then the old path calculation is used

works
fine_line([pos, dir[, range], scale]) table of vectors
  • like the old vector.line but more precise
  • needed for not round positions
  • try using minetest.line_of_sight instead
works but
old and slow
twoline(x, y) table
  • returns sth like {{0,0}, {0,1}}
  • used for a 2d line
works
threeline(x, y, z) table
  • returns sth like {{0,0,0}, {0,1,0}}
  • used for a 3d line
  • x, y and z should be round
works
sort(ps, [preferred_coords]) nil ps, which gets changed, is a list of vectors,

which become sorted by the coord in the order of preferred_coords

untested
scalar(v1, v2) number v1 and v2 are vectors, returns scalar product works
cross(v1, v2) vector v1 and v2 are vectors, returns cross product works
plane(ps) table of vectors ps is a table of three vectors

returns a list of vectors which make a filled triangle plane together

unfinished
straightdelay([s, v[, a) number
  • s = length
  • v = velocity
  • a = acceleration (optional)
works
sun_dir(t) vector
  • t = timeofday
works
inside(pos, minp, maxp) bool returns true if pos is inside or on the corners of minp and maxp untested
minmax(p1, p2) vector, vector the first vector's x, y and z are smaller than the second one's untested
move(p1, p2, s) vector
  • s = length
  • moves s to p2 from p1
  • made for rubenwardy
untested
from_number(i) vector returns {x=i, y=i, z=i} works
explosion_table(r) table
  • r = radius
  • returns sth like {{pos1, true}, {pos2}}
  • using explosion_perlin instead is recommended
works
explosion_perlin(rmin, rmax[, nparams]) table it is used to make perlin noise surface on spheres, which looks good for explosions works
circle(r) table of vectors
  • r = radius
works
ring(r) table of vectors
  • r = radius
  • r can be float
  • each positions "touch" their next ones
works
chunkcorner(pos) vector should return the chunkcorner near pos could work
point_distance_minmax(p1, p2) 2 numbers
collision(p1, p2)
get_data_from_pos(tab, z,y,x) tab[z][y][x] or nil used to get stored information in a table about these coords works
set_data_to_pos(tab, z,y,x, data) nil used to store information in a table about these coords works
set_data_to_pos_optional(tab, z,y,x, data) nil runs set_data_from_pos if get_data_from_pos returned nil there works
remove_data_from_pos(tab, z,y,x) nil used to remove information from a table about these coords works
get_data_pos_table(tab) table
  • tab was used by set_data_to_pos etc.
  • returns {{z,y,x, v}, {z,y,x, v}, …}, {x=minx, y=miny, z=minz}, {x=maxx, y=maxy, z=maxz}, count
works
update_minp_maxp(minp, maxp, pos) nil changes minp and maxp to exceed their borders works
quickadd(pos[, z,y,x]) nil adds those to pos', works more than 4.3 times as fast as using vector.add works
unpack(pos) 3 numbers returns pos.z, pos.y, pos.x works
zero {x=0, y=0, z=0} not a function works