Difference between revisions of "User:Xyz/stress"
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
http://irc.minetest.ru/minetest/2013-02-17#i_2877771 | http://irc.minetest.ru/minetest/2013-02-17#i_2877771 | ||
+ | |||
+ | == Core concepts == | ||
+ | All functions are prefixed with <code>:</code>. All properties are prefixed with <code>.</code>. | ||
== Types == | == Types == | ||
Line 25: | Line 28: | ||
== Global functions == | == Global functions == | ||
− | * <code>_ | + | * <code>_:on("event", function())</code> |
** <code>generated</code> | ** <code>generated</code> | ||
** <code>shutdown</code> | ** <code>shutdown</code> | ||
Line 42: | Line 45: | ||
if newnode.name == "default:dirt" then | if newnode.name == "default:dirt" then | ||
minetest.env:set_node(pos, {name="default:dirt_with_grass"}) | minetest.env:set_node(pos, {name="default:dirt_with_grass"}) | ||
+ | end | ||
+ | end) | ||
+ | </source> | ||
+ | |||
+ | Something more? | ||
+ | |||
+ | <source> | ||
+ | dirttograss = nil | ||
+ | _:on("chat", function(message) | ||
+ | if message == "/dirttograss" and not dirttograss then | ||
+ | dirttograss = _("default:dirt"):on("place", function(me) | ||
+ | me:value("default:dirt_with_grass") | ||
+ | end) | ||
+ | elseif message == "/nodirttograss" and dirttograss then | ||
+ | _(dirttograss):clear() | ||
end | end | ||
end) | end) | ||
</source> | </source> |
Revision as of 07:17, 18 February 2013
_()
!
http://irc.minetest.ru/minetest/2013-02-17#i_2877771
Core concepts
All functions are prefixed with :
. All properties are prefixed with .
.
Types
position
Same as position.
stressedNode
Created via _(position)
Implements:
:value()
— get node name:value("string")
— set node name (likeminetest.env:set_node()
)- something with meta?
stressedNodeDef (what a weird name! better think of another one)
Created via _("name")
, i.e. _("default:dirt")
:on("event", function())
— registers event, possible ones:dig
place
punch
rightclick
Global functions
_:on("event", function())
generated
shutdown
- …
Something
An example of code in stress:
_("default:dirt"):on("place", function(me)
me:value("default:dirt_with_grass")
end)
same without stress
minetest.register_on_placenode(function(pos, newnode)
if newnode.name == "default:dirt" then
minetest.env:set_node(pos, {name="default:dirt_with_grass"})
end
end)
Something more?
dirttograss = nil
_:on("chat", function(message)
if message == "/dirttograss" and not dirttograss then
dirttograss = _("default:dirt"):on("place", function(me)
me:value("default:dirt_with_grass")
end)
elseif message == "/nodirttograss" and dirttograss then
_(dirttograss):clear()
end
end)