pastebin

Paste #I8v -- näytä pelkkänä tekstinä -- uusi tämän pohjalta

Värjäys: Tyyli: ensimmäinen rivinumero: Tabin korvaus:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
minetest.register_craft({
	output = 'formspecname:hippopotamus',
	recipe = {{'default:stick'}},
})

minetest.register_node('formspecname:hippopotamus', {
	tiles = {'default_cloud.png', 'default_wood.png'},
	groups = {dig_immediate=2},
	on_construct = function(pos)
		local meta = minetest.get_meta(pos)
		meta:set_string("counter", "0")
	end
})

minetest.register_abm({
	nodenames = {"formspecname:hippopotamus"},
	interval = 5.0,
	chance = 1,
	action = function(pos, node, active_object_count, active_object_count_wider)
		local meta = minetest.get_meta(pos)
		local counter = tonumber(meta:get_string("counter")) or 0
		counter = counter + 1
		meta:set_string("counter", tostring(counter))

		local formname = 'formspec'..counter
		local formspec = 'field[text;'..formname..';default]'

		local objs = minetest.get_objects_inside_radius(pos, 10)
		for k, obj in pairs(objs) do
			local name = obj:get_player_name()
			if name then
				minetest.show_formspec(name, formname, formspec)
			end
		end
	end,
})

minetest.register_on_player_receive_fields(function(player, formname, fields)
	print("on_player_receive_fields("..player:get_player_name()..","..formname..",fields)")
end)