summaryrefslogtreecommitdiff
path: root/titanium/init.lua
blob: 28dca9533a0705f8bf0478492992093e7a9a416e (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
---
---Titanium Mod Version 4 By Aqua. Added new Google Glass Titanium. Be nice this is my first mod!!! Subscribe to my YouTube: youtube.com/theshaunzero!
---

---
---blocks
---

local enable_walking_light = minetest.setting_getbool("titanium_walking_light")
if enable_walking_light ~= false then
	enable_walking_light = true
end

minetest.register_node( "titanium:titanium_in_ground", {
	description = "Titanium Ore",
	tile_images = { "default_stone.png^titanium_titanium_in_ground.png" },
	is_ground_content = true,
	groups = {cracky=1},
	sounds = default.node_sound_stone_defaults(),
	drop = 'craft "titanium:titanium" 1',
})

minetest.register_node( "titanium:block", {
	description = "Titanium Block",
	tile_images = { "titanium_block.png" },
	is_ground_content = true,
	groups = {cracky=1},
	sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("titanium:glass", {
	description = "Titanium Glass",
	drawtype = "glasslike",
	tile_images = {"titanium_glass.png"},
	light_propagates = true,
	paramtype = "light",
	sunlight_propagates = true,
	is_ground_content = true,
	groups = {snappy=1,cracky=2,oddly_breakable_by_hand=2},
	sounds = default.node_sound_glass_defaults(),
})

minetest.register_craftitem( "titanium:titanium", {
	description = "Titanium",
	inventory_image = "titanium_titanium.png",
	on_place_on_ground = minetest.craftitem_place_item,
})

minetest.register_craftitem( "titanium:tougher_titanium", {
	description = "Tougher Titanium",
	inventory_image = "tougher_titanium.png",
	on_place_on_ground = minetest.craftitem_place_item,
})

minetest.register_node( "titanium:titanium_plate", {
	description = "Titanium Plate",
	tile_images = {"titanium_plate.png"},
	inventory_image = "titanium_plate.png",
	is_ground_content = true,
	groups = {cracky=1},
	sounds = default.node_sound_stone_defaults(),
})

minetest.register_node( "titanium:titanium_tv_1", {
	description = "Titanium TV",
	tile_images = { "titanium_tv_1.png" },
	is_ground_content = true,
	groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
	drop = 'titanium:screen_1',
	light_source = 8,
})

minetest.register_node( "titanium:titanium_tv_2", {
	description = "Titanium TV",
	tile_images = { "titanium_tv_2.png" },
	is_ground_content = true,
	groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
	drop = 'titanium:screen_1',
	light_source = 8,
})

minetest.register_abm(
        {nodenames = {"titanium:titanium_tv_1", "titanium:titanium_tv_2"}, 
        interval = 12,
        chance = 1,
        action = function(pos)
		local i = math.random(1,2)
        
			if i== 1 then
				minetest.add_node(pos,{name="titanium:titanium_tv_1"})
			end
		
			if i== 2 then
				minetest.add_node(pos,{name="titanium:titanium_tv_2"})
			end
			
       end 
})
			
---
---tools
---

minetest.register_tool("titanium:sword", {
	description = "Titanium Sword",
	inventory_image = "titanium_sword.png",
	tool_capabilities = {
		full_punch_interval = 1.0,
		max_drop_level=1,
		groupcaps={
			fleshy={times={[1]=2.00, [2]=0.60, [3]=0.20}, uses=100, maxlevel=2},
			snappy={times={[2]=0.60, [3]=0.20}, uses=100, maxlevel=1},
			choppy={times={[3]=0.70}, uses=100, maxlevel=0}
		}
	}
})

minetest.register_tool("titanium:axe", {
	description = "Titanium Axe",
	inventory_image = "titanium_axe.png",
	tool_capabilities = {
		max_drop_level=1,
		groupcaps={
			choppy={times={[1]=2.50, [2]=1.50, [3]=1.00}, uses=150, maxlevel=2},
			fleshy={times={[2]=1.00, [3]=0.50}, uses=120, maxlevel=1}
		}
	},
})

minetest.register_tool("titanium:shovel", {
	description = "Titanium Shovel",
	inventory_image = "titanium_shovel.png",
	tool_capabilities = {
		max_drop_level=1,
		groupcaps={
			crumbly={times={[1]=1.0, [2]=0.50, [3]=0.50}, uses=150, maxlevel=3}
		}
	},
})
	
	minetest.register_tool("titanium:pick", {
	description = "Titanium Pickaxe",
	inventory_image = "titanium_pick.png",
	tool_capabilities = {
		full_punch_interval = 1.0,
		max_drop_level=3,
		groupcaps={
			cracky={times={[1]=2.4, [2]=1.0, [3]=0.6}, uses=160, maxlevel=3},
			crumbly={times={[1]=2.4, [2]=1.0, [3]=0.6}, uses=160, maxlevel=3},
			snappy={times={[1]=2.4, [2]=1.0, [3]=0.6}, uses=160, maxlevel=3}
		}
	},
})

---
---crafting
---

minetest.register_craft({
	output = 'titanium:pick',
	recipe = {
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
		{'', 'default:stick', ''},
		{'', 'default:stick', ''},
	}
})

minetest.register_craft({
	output = 'titanium:axe',
	recipe = {
		{'titanium:titanium', 'titanium:titanium', ''},
		{'titanium:titanium', 'default:stick', ''},
		{'', 'default:stick', ''},
	}
})

minetest.register_craft({
	output = 'titanium:shovel',
	recipe = {
		{'', 'titanium:titanium', ''},
		{'', 'default:stick', ''},
		{'', 'default:stick', ''},
	}
})

minetest.register_craft({
	output = 'titanium:sword',
	recipe = {
		{'', 'titanium:titanium', ''},
		{'', 'titanium:titanium', ''},
		{'', 'default:stick', ''},
	}
})

minetest.register_craft({
	output = 'titanium:block',
	recipe = {
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
	}
})

minetest.register_craft({
	output = 'titanium:titanium 9',
	recipe = {
		{'', 'titanium:block', ''},
	}
})

minetest.register_craft({
	output = 'titanium:glass 3',
	recipe = {
		{'', 'titanium:titanium', ''},
		{'titanium:titanium', 'default:glass', 'titanium:titanium'},
		{'', 'titanium:titanium', ''},
	}
})

minetest.register_craft({
	output = 'titanium:tougher_titanium',
	recipe = {
		{'titanium:titanium', 'titanium:titanium'},
		{'titanium:titanium', 'titanium:titanium'},
	}
})

minetest.register_craft({
	output = 'titanium:titanium_tv_1',
	recipe = {
		{'default:steel_ingot', 'titanium:tougher_titanium', 'default:steel_ingot'},
		{'titanium:tougher_titanium', 'default:glass', 'titanium:tougher_titanium'},
		{'default:steel_ingot', 'titanium:tougher_titanium', 'default:steel_ingot'},
	}
})

minetest.register_craft({
	output = 'titanium:titanium_plate 9',
	recipe = {
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
		{'titanium:titanium', 'titanium:tougher_titanium', 'titanium:titanium'},
		{'titanium:titanium', 'titanium:titanium', 'titanium:titanium'},
	}
})

minetest.register_ore({
	ore_type = "scatter",
	ore =      "titanium:titanium_in_ground",
	wherein =  "default:stone",
	noise_params = {
		offset = 0,
		scale = 1,
		spread = {x=100, y=100, z=100},
		seed = 21,
		octaves = 2,
		persist = 0.70,
	},
	clust_scarcity = 8192,
	clust_num_ores = 5,
	clust_size = 2,
	y_min = -31000,
	y_max = -1500,
})

if enable_walking_light then

	local players = {}
	local player_positions = {}
	local last_wielded = {}

	function round(num) 
		return math.floor(num + 0.5) 
	end

	function check_for_googles (player)
	if player==nil then return false end
	local inv = player:get_inventory()
	local hotbar=inv:get_list("main")
	for index=1,8,1 do
		if hotbar[index]:get_name() == "titanium:sam_titanium" then
			return "titanium:sam_titanium"
		end
	end
	return false
	end   

	minetest.register_on_joinplayer(function(player)
		local player_name = player:get_player_name()
		table.insert(players, player_name)
		last_wielded[player_name] = player:get_wielded_item():get_name()
		local pos = player:getpos()
		local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
		local wielded_item = check_for_googles(player)
		if wielded_item ~= "titanium:sam_titanium" then
			minetest.add_node(rounded_pos,{type="node",name="titanium:who_knows"})
			minetest.add_node(rounded_pos,{type="node",name="air"})
		end
		player_positions[player_name] = {}
		player_positions[player_name]["x"] = rounded_pos.x;
		player_positions[player_name]["y"] = rounded_pos.y;
		player_positions[player_name]["z"] = rounded_pos.z;
	end)

	minetest.register_on_leaveplayer(function(player)
		local player_name = player:get_player_name()
		for i,v in ipairs(players) do
			if v == player_name then 
				table.remove(players, i)
				last_wielded[player_name] = nil
				local pos = player:getpos()
				local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
				minetest.add_node(rounded_pos,{type="node",name="titanium:who_knows"})
				minetest.add_node(rounded_pos,{type="node",name="air"})
				player_positions[player_name]["x"] = nil
				player_positions[player_name]["y"] = nil
				player_positions[player_name]["z"] = nil
				player_positions[player_name]["m"] = nil
				player_positions[player_name] = nil
			end
		end
	end)

	minetest.register_globalstep(function(dtime)
		for i,player_name in ipairs(players) do
			local player = minetest.get_player_by_name(player_name)
			local wielded_item = check_for_googles(player)
			if wielded_item == "titanium:sam_titanium" then
				local pos = player:getpos()
				local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
				if (last_wielded[player_name] ~= "titanium:sam_titanium") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
					local is_air  = minetest.get_node_or_nil(rounded_pos)
					if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "titanium:light")) then
						minetest.add_node(rounded_pos,{type="node",name="titanium:light"})
					end
					if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
						local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
						local is_light = minetest.get_node_or_nil(old_pos)
						if is_light ~= nil and is_light.name == "titanium:light" then
							minetest.add_node(old_pos,{type="node",name="titanium:who_knows"})
							minetest.add_node(old_pos,{type="node",name="air"})
						end
					end
					player_positions[player_name]["x"] = rounded_pos.x
					player_positions[player_name]["y"] = rounded_pos.y
					player_positions[player_name]["z"] = rounded_pos.z
				end

				last_wielded[player_name] = wielded_item;
			elseif last_wielded[player_name] == "titanium:sam_titanium" then
				local pos = player:getpos()
				local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
				repeat
					local is_light  = minetest.get_node_or_nil(rounded_pos)
					if is_light ~= nil and is_light.name == "titanium:light" then
						minetest.add_node(rounded_pos,{type="node",name="titanium:who_knows"})
						minetest.add_node(rounded_pos,{type="node",name="air"})
					end
				until minetest.get_node_or_nil(rounded_pos) ~= "titanium:light"
				local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
				repeat
					is_light  = minetest.get_node_or_nil(old_pos)
					if is_light ~= nil and is_light.name == "titanium:light" then
						minetest.add_node(old_pos,{type="node",name="titanium:who_knows"})
						minetest.add_node(old_pos,{type="node",name="air"})
					end
				until minetest.get_node_or_nil(old_pos) ~= "titanium:light"
				last_wielded[player_name] = wielded_item
			end
		end
	end)

	------------------------------------------------------
	-- Version 4------------------------------------------

	minetest.register_node("titanium:light", {
		drawtype = "glasslike",
		tile_images = {"titanium.png"},
		inventory_image = minetest.inventorycube("titanium.png"),
		paramtype = "light",
		walkable = false,
		is_ground_content = true,
		light_propagates = true,
		sunlight_propagates = true,
		light_source = 11,
		selection_box = {
			type = "fixed",
			fixed = {0, 0, 0, 0, 0, 0},
		},
	})

	minetest.register_tool("titanium:sam_titanium", {
		description = "Google Glass Titanium",
		inventory_image = "sam_titanium.png",
		wield_image = "sam_titanium.png",
		tool_capabilities = {
			max_drop_level=1,
			groupcaps={
					cracky={times={[2]=1.20, [3]=0.80}, uses=5, maxlevel=1}
			}
		},
	})

	minetest.register_craft({
		output = 'titanium:sam_titanium',
		recipe = {
			{'titanium:titanium_plate', 'default:torch', 'titanium:titanium_plate'},
			{'titanium:glass', 'default:mese_crystal', 'titanium:glass'},
			{'', '', ''},
		}
	})
	--------------------------------------------------------
	minetest.register_node("titanium:who_knows", {
		description = "?Who Knows?",
		tiles = {"titanium.png"},
		is_ground_content = true,
		groups = {not_in_creative_inventory=1},
	})
end

print("[Titanium Mod] Loaded! By Aqua! Subscribe to my YouTube: youtube.com/theshaunzero!")