Difference between revisions of "User:Hybrid Dog"
Jump to navigation
Jump to search
Hybrid Dog (talk | contribs) |
Hybrid Dog (talk | contribs) (move vector_extras) |
||
Line 45: | Line 45: | ||
return true | return true | ||
end)</source> | end)</source> | ||
+ | |||
+ | [[Category:Methods]] | ||
+ | |||
+ | == Mods/vector_extras == | ||
+ | {| class="wikitable collapsible sortable" | ||
+ | ! Function | ||
+ | ! Return value | ||
+ | ! Comments | ||
+ | ! Status | ||
+ | |- | ||
+ | |<source enclose="none">vector.line([pos, dir[, range]])</source> | ||
+ | | table of [[vector]]s | ||
+ | | dir can be following: | ||
+ | * a direction | ||
+ | * a [[position]] (range not needed) | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.fine_line([pos, dir[, range], scale])</source> | ||
+ | | table of [[vector]]s | ||
+ | | | ||
+ | * like vector.line but more precise | ||
+ | * needed for not round positions | ||
+ | | works but slow | ||
+ | |- | ||
+ | |<source enclose="none">vector.straightdelay([s, v[, a]])</source> | ||
+ | | number | ||
+ | | | ||
+ | * s = length | ||
+ | * v = velocity | ||
+ | * a = acceleration (optional) | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.sun_dir(t)</source> | ||
+ | | [[vector]] | ||
+ | | | ||
+ | * t = timeofday | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.inside(pos, minp, maxp)</source> | ||
+ | | bool | ||
+ | | returns true if pos is inside or on the corners of minp and maxp | ||
+ | | untested | ||
+ | |- | ||
+ | |<source enclose="none">vector.minmax(p1, p2)</source> | ||
+ | | [[vector]], [[vector]] | ||
+ | | the first [[vector]]'s x, y and z are smaller than the second one's | ||
+ | | untested | ||
+ | |- | ||
+ | |<source enclose="none">vector.move(p1, p2, s)</source> | ||
+ | | [[vector]] | ||
+ | | | ||
+ | * s = length | ||
+ | * moves s to p2 from p1 | ||
+ | * made for rubenwardy | ||
+ | | untested | ||
+ | |- | ||
+ | |<source enclose="none">vector.explosion_table(r)</source> | ||
+ | | table | ||
+ | | | ||
+ | * r = radius | ||
+ | * returns sth like <source enclose="none">{{pos1, true}, {pos2}}</source> | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.circle(r)</source> | ||
+ | | table of [[vector]]s | ||
+ | | | ||
+ | * r = radius | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.ring(r)</source> | ||
+ | | table of [[vector]]s | ||
+ | | | ||
+ | * r = radius | ||
+ | * r can be float | ||
+ | * each positions "touch" their next ones | ||
+ | | works | ||
+ | |- | ||
+ | |<source enclose="none">vector.chunkcorner(pos)</source> | ||
+ | | [[vector]] | ||
+ | | should return the chunkcorner near pos | ||
+ | | could work | ||
+ | |} | ||
+ | |||
+ | [[Category:Mod]] |
Revision as of 16:55, 27 May 2014
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(itemstack, placer, pointed_thing)
if func(itemstack, placer, pointed_thing) then
return previous_on_place(itemstack, placer, pointed_thing)
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)
Mods/vector_extras
Function | Return value | Comments | Status |
---|---|---|---|
vector.line([pos, dir[, range]])
|
table of vectors | dir can be following:
|
works |
vector.fine_line([pos, dir[, range], scale])
|
table of vectors |
|
works but slow |
vector.straightdelay([s, v[, a]])
|
number |
|
works |
vector.sun_dir(t)
|
vector |
|
works |
vector.inside(pos, minp, maxp)
|
bool | returns true if pos is inside or on the corners of minp and maxp | untested |
vector.minmax(p1, p2)
|
vector, vector | the first vector's x, y and z are smaller than the second one's | untested |
vector.move(p1, p2, s)
|
vector |
|
untested |
vector.explosion_table(r)
|
table |
|
works |
vector.circle(r)
|
table of vectors |
|
works |
vector.ring(r)
|
table of vectors |
|
works |
vector.chunkcorner(pos)
|
vector | should return the chunkcorner near pos | could work |