sorcery  Diff

Differences From Artifact [080406f8d2]:

To Artifact [7e265da854]:


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
...
234
235
236
237
238
239
240

241
242
243
244
245
246
247
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
		local props = object:get_properties()
		local node = minetest.get_node(pos)
		props.wield_item = itemstring
		object:set_properties(props)
		object:set_yaw(math.pi*2 - node.param2*(math.pi / 2))
	end
end













for name, god in pairs(sorcery.data.gods) do
	local hitbox = {
		0-(god.idol.width / 2.0), 0-(god.idol.height / 2.0), -0.15,
		   god.idol.width / 2.0,     god.idol.height / 2.0,   0.15
	} -- {xmin, ymin, zmin,
	  -- xmax, ymax, zmax} in nodes from node center.
	paramtype = "light";
	minetest.register_node('sorcery:idol_' .. name, {
		description = god.idol.desc;
		drawtype = "mesh";
		mesh = 'sorcery-idol-' .. name .. '.obj';
		paramtype = 'light';
		paramtype2 = 'facedir';
		sunlight_propagates = true;
		stack_max = 1;
		tiles = god.idol.tex;
		selection_box = { type = "fixed"; fixed = {hitbox}; };
		collision_box = { type = "fixed"; fixed = {hitbox}; };
		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1};

		after_place_node = function(pos, placer, stack, pointat)
			local meta = minetest.get_meta(pos)
			local stackmeta = stack:get_meta()
			meta:set_int('favor', stackmeta:get_int('favor'))
			meta:set_string('last_sacrifice', stackmeta:get_string('last_sacrifice'))

			minetest.get_node_timer(pos):start(1)
		end;

		drop = {
			-- for some idiot reason this is necessary for
			-- preserve_metadata to work right
			max_items = 1;
			items = {
				{ items = {'sorcery:idol_' .. name} }
			};
		};

		preserve_metadata = function(pos, node, meta, newstack)
			newstack[1]:get_meta():from_table(meta)
		end;

		on_timer = function(pos, elapsed)
			local altar = minetest.find_node_near(pos, 3, "sorcery:altar")
			-- TODO even without an altar, an idol with high favor could still be the source of miracles

			if not altar then return true end

			local altarmeta = minetest.get_meta(altar)
			local inv = altarmeta:get_inventory()
			local idolmeta = minetest.get_meta(pos)
			local divine_favor = idolmeta:get_int('favor')
			local bestow = function(item,color)
................................................................................
							}
						end
						-- preserve wear
						local gift
						if type(tx) == 'string' then
							gift = ItemStack(tx)
						else gift = tx end

						local wear = stack:get_wear()
						if wear > 0 then
							gift:set_wear(wear)
						end
						-- preserve meta
						local gm = gift:get_meta()
						gm:from_table(
................................................................................
						if divine_favor >= cost then
							bestow(gift)
							divine_favor = divine_favor - cost
							log.act(god.name, 'has consecrated', s, 'into', tx, 'for the cost of', cost, 'points of divine favor')
							goto refresh
						end
					end
				end
			end

			::refresh::
			idolmeta:set_int('favor', divine_favor)
			update_altar(altar,nil)
			return true
		end;







>
>
>
>
>
>
>
>
>
>
>
>








|












|
<
<
<
<
<



<
<
<
<
<
<
<
<
<
<
<
<
<



>







 







>







 







|







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
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
		local props = object:get_properties()
		local node = minetest.get_node(pos)
		props.wield_item = itemstring
		object:set_properties(props)
		object:set_yaw(math.pi*2 - node.param2*(math.pi / 2))
	end
end

-- remove unknown gifts
minetest.register_on_mods_loaded(function()
	for name, god in pairs(sorcery.data.gods) do
		local bad = {}
		for g in pairs(god.gifts) do
			-- can't mutate table while we're iterating it
			if not minetest.registered_nodes[g] then bad[#bad+1] = g end
		end
		for _, g in ipairs(bad) do god.gifts[g] = nil end
	end
end)

for name, god in pairs(sorcery.data.gods) do
	local hitbox = {
		0-(god.idol.width / 2.0), 0-(god.idol.height / 2.0), -0.15,
		   god.idol.width / 2.0,     god.idol.height / 2.0,   0.15
	} -- {xmin, ymin, zmin,
	  -- xmax, ymax, zmax} in nodes from node center.
	paramtype = "light";
	sorcery.lib.node.reg_autopreserve('sorcery:idol_' .. name, {
		description = god.idol.desc;
		drawtype = "mesh";
		mesh = 'sorcery-idol-' .. name .. '.obj';
		paramtype = 'light';
		paramtype2 = 'facedir';
		sunlight_propagates = true;
		stack_max = 1;
		tiles = god.idol.tex;
		selection_box = { type = "fixed"; fixed = {hitbox}; };
		collision_box = { type = "fixed"; fixed = {hitbox}; };
		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1};

		on_construct = function(pos)





			minetest.get_node_timer(pos):start(1)
		end;














		on_timer = function(pos, elapsed)
			local altar = minetest.find_node_near(pos, 3, "sorcery:altar")
			-- TODO even without an altar, an idol with high favor could still be the source of miracles
			-- refills nearby partly empty troughs at cost to favor?
			if not altar then return true end

			local altarmeta = minetest.get_meta(altar)
			local inv = altarmeta:get_inventory()
			local idolmeta = minetest.get_meta(pos)
			local divine_favor = idolmeta:get_int('favor')
			local bestow = function(item,color)
................................................................................
							}
						end
						-- preserve wear
						local gift
						if type(tx) == 'string' then
							gift = ItemStack(tx)
						else gift = tx end
						if not gift:is_known() then goto skip end
						local wear = stack:get_wear()
						if wear > 0 then
							gift:set_wear(wear)
						end
						-- preserve meta
						local gm = gift:get_meta()
						gm:from_table(
................................................................................
						if divine_favor >= cost then
							bestow(gift)
							divine_favor = divine_favor - cost
							log.act(god.name, 'has consecrated', s, 'into', tx, 'for the cost of', cost, 'points of divine favor')
							goto refresh
						end
					end
				::skip::end
			end

			::refresh::
			idolmeta:set_int('favor', divine_favor)
			update_altar(altar,nil)
			return true
		end;