aboutsummaryrefslogtreecommitdiff
path: root/debugitems.lua
blob: 5cb66305aecaf94426e7ed855f3b5728c3ef644a (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

minetest.register_tool("advtrains:1",
	{
		description = "1",
		groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
		inventory_image = "drwho_screwdriver.png",
		wield_image = "drwho_screwdriver.png",
		stack_max = 1,
		range = 7.0,
	on_use = function(itemstack, user, pointed_thing)
	pos1=pointed_thing.under
end,
})
minetest.register_tool("advtrains:2",
	{
		description = "2",
		groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
		inventory_image = "drwho_screwdriver.png",
		wield_image = "drwho_screwdriver.png",
		stack_max = 1,
		range = 7.0,
		on_use = function(itemstack, user, pointed_thing)
		pos2=pointed_thing.under
	end,
})
minetest.register_tool("advtrains:3",
	{
		description = "3",
		groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
		inventory_image = "drwho_screwdriver.png",
		wield_image = "drwho_screwdriver.png",
		stack_max = 1,
		range = 7.0,
		on_use = function(itemstack, user, pointed_thing)
		pos3=pointed_thing.under
	end,
})
minetest.register_tool("advtrains:4",
	{
		description = "4",
		groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
		inventory_image = "drwho_screwdriver.png",
		wield_image = "drwho_screwdriver.png",
		stack_max = 1,
		range = 7.0,
		on_use = function(itemstack, user, pointed_thing)
		pos4=pointed_thing.under
	end,
})
core.register_chatcommand("mad", {
	params="",
	description="",
	privs={},
	func = function(name, param)
	return true, advtrains.get_wagon_yaw(pos1, pos2, pos3, pos4, tonumber(param))*360/(2*math.pi)
end,
})

advtrains.firstobject=nil
minetest.register_tool("advtrains:connect",
{
	description = "connect wagons tool",
	groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
	inventory_image = "drwho_screwdriver.png",
	wield_image = "drwho_screwdriver.png",
	stack_max = 1,
	range = 7.0,
		
	on_place = function(itemstack, placer, pointed_thing)
	
	end,
	--[[
	^ Shall place item and return the leftover itemstack
	^ default: minetest.item_place ]]
	on_use = function(itemstack, user, pointed_thing)
		if pointed_thing.type=="object" then
			local luaent=pointed_thing.ref:get_luaentity()
			if luaent and luaent.is_wagon then
				if advtrains.firstobject then
					minetest.chat_send_all("connect second object "..luaent.unique_id)
					advtrains.connect_wagons(luaent, advtrains.firstobject)
					minetest.chat_send_all("done")
					advtrains.firstobject=nil
				else
					advtrains.firstobject=luaent
					minetest.chat_send_all("connect first object "..luaent.unique_id)
				end
			end
		end
	end,
--[[
^  default: nil
^ Function must return either nil if no item shall be removed from
inventory, or an itemstack to replace the original itemstack.
e.g. itemstack:take_item(); return itemstack
^ Otherwise, the function is free to do what it wants.
^ The default functions handle regular use cases.
]]
})
minetest.register_tool("advtrains:tunnelborer",
{
	description = "tunnelborer",
	groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
	inventory_image = "drwho_screwdriver.png",
	wield_image = "drwho_screwdriver.png",
	stack_max = 1,
	range = 7.0,
		
	on_place = function(itemstack, placer, pointed_thing)
	
	end,
	--[[
	^ Shall place item and return the leftover itemstack
	^ default: minetest.item_place ]]
	on_use = function(itemstack, user, pointed_thing)
		if pointed_thing.type=="node" then
			for x=-1,1 do
				for y=-1,1 do
					for z=-1,1 do
						minetest.remove_node(vector.add(pointed_thing.under, {x=x, y=y, z=z}))
					end
				end
			end
		end
	end,
--[[
^  default: nil
^ Function must return either nil if no item shall be removed from
inventory, or an itemstack to replace the original itemstack.
e.g. itemstack:take_item(); return itemstack
^ Otherwise, the function is free to do what it wants.
^ The default functions handle regular use cases.
]]
}
)