sorcery  Check-in [d44d0ac782]

Overview
Comment:add beds, external lights, fix various glitches
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d44d0ac782a0dcf639194de13568149a8ba3ac78097095132b773c56bf5107e8
User & Date: lexi on 2021-07-24 01:01:50
Other Links: manifest | tags
Context
2021-07-31
19:13
optimize pngs, finish spellshatter spell, tweak rune forge algorithm to be more fair & reasonable, new spell-casting vfx check-in: cb09c77754 user: lexi tags: trunk
2021-07-24
01:01
add beds, external lights, fix various glitches check-in: d44d0ac782 user: lexi tags: trunk
2021-07-23
22:48
fix textures, add wires, add more magitech parts check-in: 49345366f9 user: lexi tags: trunk
Changes

Modified data/runes.lua from [27c07e8c34] to [67a4930ba7].

1158
1159
1160
1161
1162
1163
1164

1165
1166
1167
1168
1169
1170
1171
....
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
....
1332
1333
1334
1335
1336
1337
1338








1339
1340
1341
1342
1343
1344
1345
....
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
....
1388
1389
1390
1391
1392
1393
1394
1395

1396
1397
1398
1399
1400
1401

1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
....
1420
1421
1422
1423
1424
1425
1426








































1427
1428
1429
1430
1431
1432
1433
						end
						if next(a) then
							table.insert(ary, a)
							return true
						end
						return false
					end

					for name,tree in pairs(sorcery.data.trees) do
						try(materials.corners, tree.node)
						try(materials.walls, tree.plank)
						try(materials.floor, tree.plank)
					end
					try(materials.roof, 'farming:straw')
					try(materials.floor, 'farming:straw')
................................................................................
					try(materials.corners, 'default:desert_sandstone_brick')
					try(materials.corners, 'default:silver_sandstone_brick')
					if math.random(1,10) == 7 then
					try(materials.corners, 'default:obsidianbrick')
					end

					try(materials.lamp_wall, 'default:torch_wall')
					try(materials.lamp_wall, 'morelights_modern:wall_lamp')

					try(materials.lamp_ext, 'default:torch')
					try(materials.lamp_ext, 'morelights_modern:wall_lamp')
					try(materials.lamp_ext, 'morelights_modern:lantern_f')

					for _, l in pairs {
						'default:meselamp';
						'morelights_modern:barlight_s';
						'morelights_modern:ceilinglight';
						'morelights_modern:canlight_d';
						'morelights_modern:canlight_l';
................................................................................
								minetest.set_node(ctr:offset( dim.rx,y,z), {name=mpick'walls'})
							end
						end
						i=i+1
					end
					local t_built = per*i
					local lighting = math.random(1,2)








					if lighting == 1 then
						local lh = math.ceil(dim.y * .6)
						local wlamps = {
							ctr:offset(  dim.rx - 1 , lh,0);
							ctr:offset(-(dim.rx - 1), lh,0);
							ctr:offset(0, lh,   dim.rz - 1);
							ctr:offset(0, lh, -(dim.rz - 1));
................................................................................
						sorcery.lib.tbl.shuffle(wlamps)
						for _, where in pairs(wlamps) do
							i = i + 10
							timeline[{whence=0, secs = per*i}] = function(s)
								spark(s,where)
								local node = select(2,sorcery.lib.tbl.pick(materials.lamp_wall))
								minetest.sound_play('sorcery_put',{pos=where,gain=0.8},true)
								minetest.set_node(where, {
									name=node;
									param2=minetest.dir_to_wallmounted(vector.normalize(ctr:offset(0,lh,0) - where)*-1);
								})
							end
						end i=i+1
					elseif lighting == 2 then
						local which = math.random(1,3)
						if which == 1 or which == 2 then
							i = i + 20
							timeline[{whence=0, secs = per*i}] = function(s)
................................................................................
									minetest.sound_play('sorcery_put',{pos=v,gain=0.7},true)
									minetest.set_node(v, {name = node})
								end
								i = i + 7
							end
						end
					end
					-- install door

					local doorside = ({
						vector.new( dim.rx,1,0);
						vector.new(0,1, dim.rz);
						vector.new(-dim.rx,1,0);
						vector.new(0,1,-dim.rz);
					})[math.random(1,4)]

					local doorpos
					if math.random(1,3) == 1 then
						if doorside.z ~= 0 then
							doorside.x = doorside.x + math.random(-(dim.rx-1), dim.rx-1)
						elseif doorside.x ~= 0 then
							doorside.z = doorside.z + math.random(-(dim.rz-1), dim.rz-1)
						end
					end
					doorpos = ctr + doorside
					local door = mpick'door'
					i=i+5
					timeline[{whence=0,secs=per*i}] = function(s)
						minetest.remove_node(doorpos)
						minetest.remove_node(doorpos:offset(0,1,0))
................................................................................
-- 						local d = ItemStack(door)
-- 						d:get_definition().on_place(d, s.caster, {
-- 							type = 'node';
-- 							above = doorpos;
-- 							under = doorpos:offset(0,-1,0);
-- 						})
					end









































					sorcery.spell.cast {
						name = 'sorcery:shelter';
						groups = {'genesis','construct'};
						caster = ctx.caster;
						anchor = ctr;
						radius = math.max(dim.rz, dim.rx);







>







 







|

|
|
|







 







>
>
>
>
>
>
>
>







 







<
<
|
<







 







|
>






>


<
|
|
<
<







 







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







1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
....
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
....
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
....
1356
1357
1358
1359
1360
1361
1362


1363

1364
1365
1366
1367
1368
1369
1370
....
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411

1412
1413


1414
1415
1416
1417
1418
1419
1420
....
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
						end
						if next(a) then
							table.insert(ary, a)
							return true
						end
						return false
					end
					local daytime = minetest.get_natural_light(ctr:offset(0,1,0)) > 9
					for name,tree in pairs(sorcery.data.trees) do
						try(materials.corners, tree.node)
						try(materials.walls, tree.plank)
						try(materials.floor, tree.plank)
					end
					try(materials.roof, 'farming:straw')
					try(materials.floor, 'farming:straw')
................................................................................
					try(materials.corners, 'default:desert_sandstone_brick')
					try(materials.corners, 'default:silver_sandstone_brick')
					if math.random(1,10) == 7 then
					try(materials.corners, 'default:obsidianbrick')
					end

					try(materials.lamp_wall, 'default:torch_wall')
					try(materials.lamp_wall, 'morelights_modern:walllamp')

					try(materials.lamp_ext, 'default:torch_wall')
					try(materials.lamp_ext, 'morelights_modern:walllamp')
					try(materials.lamp_ext, 'morelights_vintage:lantern_w')

					for _, l in pairs {
						'default:meselamp';
						'morelights_modern:barlight_s';
						'morelights_modern:ceilinglight';
						'morelights_modern:canlight_d';
						'morelights_modern:canlight_l';
................................................................................
								minetest.set_node(ctr:offset( dim.rx,y,z), {name=mpick'walls'})
							end
						end
						i=i+1
					end
					local t_built = per*i
					local lighting = math.random(1,2)
					local put_align = function(where,node,dir)
						local dfn = function() return 0 end
						local pt2 = minetest.registered_nodes[node].paramtype2
						if pt2 == 'facedir' or pt2 == 'wallmounted' then
							dfn = minetest['dir_to_' .. pt2]
						end
						minetest.set_node(where, { name=node, param2=dfn(dir) })
					end
					if lighting == 1 then
						local lh = math.ceil(dim.y * .6)
						local wlamps = {
							ctr:offset(  dim.rx - 1 , lh,0);
							ctr:offset(-(dim.rx - 1), lh,0);
							ctr:offset(0, lh,   dim.rz - 1);
							ctr:offset(0, lh, -(dim.rz - 1));
................................................................................
						sorcery.lib.tbl.shuffle(wlamps)
						for _, where in pairs(wlamps) do
							i = i + 10
							timeline[{whence=0, secs = per*i}] = function(s)
								spark(s,where)
								local node = select(2,sorcery.lib.tbl.pick(materials.lamp_wall))
								minetest.sound_play('sorcery_put',{pos=where,gain=0.8},true)


								put_align(where, node, vector.normalize(ctr:offset(0,lh,0) - where)*-1)

							end
						end i=i+1
					elseif lighting == 2 then
						local which = math.random(1,3)
						if which == 1 or which == 2 then
							i = i + 20
							timeline[{whence=0, secs = per*i}] = function(s)
................................................................................
									minetest.sound_play('sorcery_put',{pos=v,gain=0.7},true)
									minetest.set_node(v, {name = node})
								end
								i = i + 7
							end
						end
					end

					-- cut out door
					local doorside = ({
						vector.new( dim.rx,1,0);
						vector.new(0,1, dim.rz);
						vector.new(-dim.rx,1,0);
						vector.new(0,1,-dim.rz);
					})[math.random(1,4)]
					local doorslideaxis = doorside.z ~= 0 and 'x' or 'z'
					local doorpos
					if math.random(1,3) == 1 then

						local d = dim['r'..doorslideaxis] - 1
						doorside[doorslideaxis] = doorside[doorslideaxis] + math.random(-d,d)


					end
					doorpos = ctr + doorside
					local door = mpick'door'
					i=i+5
					timeline[{whence=0,secs=per*i}] = function(s)
						minetest.remove_node(doorpos)
						minetest.remove_node(doorpos:offset(0,1,0))
................................................................................
-- 						local d = ItemStack(door)
-- 						d:get_definition().on_place(d, s.caster, {
-- 							type = 'node';
-- 							above = doorpos;
-- 							under = doorpos:offset(0,-1,0);
-- 						})
					end

					-- install outdoor lighting
					if math.random(1,7) == 1 or not daytime then
						local xwall,xspc = dim.rx, dim.rx+1
						local zwall,zspc = dim.rz, dim.rz+1
						local lh = dim.y - 1
						for _, o in pairs(sorcery.lib.node.offsets.corners) do
							local w = ctr:add {
								z = dim.rz * o.z;
								x = dim.rx * o.x;
								y = lh;
							}
							local put = function(ofs)
								timeline[{whence=0,secs=per*i}] = function(s)
									local p = vector.add(w,ofs)
									if not sorcery.lib.node.is_clear(p) then return end
									spark(s, p)
									minetest.sound_play('sorcery_put', {pos = p, gain = 0.4}, true)
									local lamp = mpick 'lamp_ext'
									print('installing lamp',lamp,p,vector.new(ofs))
									put_align(p, lamp, vector.multiply(ofs,-1))
								end
								i=i+1
							end
							put{x=o.x, y=0, z=0}
							put{x=0,   y=0, z=o.z}
						end
					end

					-- lay down bed
					i=i+3
					timeline[{whence=0,secs=per*i}] = function(s)
						local bed = 'beds:bed'
						if math.random(1,3) == 1 then bed = 'beds:fancy_bed' end
						local top = ctr:offset(dim.rx-1,1,dim.rz-1)
						sorcery.lib.node.install_bed(bed, top, vector.new(1,0,0))
						spark(s, top)
						spark(s, top:offset(-1,0,0))
						minetest.sound_play('sorcery_put', {pos = doorpos, gain = 0.9}, true)
					end

					sorcery.spell.cast {
						name = 'sorcery:shelter';
						groups = {'genesis','construct'};
						caster = ctx.caster;
						anchor = ctr;
						radius = math.max(dim.rz, dim.rx);

Modified lib/node.lua from [1c278a4b1d] to [f2e6b0cbe1].

4
5
6
7
8
9
10






11
12
13
14
15
16
17
...
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
...
152
153
154
155
156
157
158
















159
160
161
162
163
164
165
...
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
		{x =  0, y =  1, z =  0};
		{x =  0, y = -1, z =  0};
		{x =  1, y =  0, z =  0};
		{x = -1, y =  0, z =  0};
		{x =  0, y =  0, z =  1};
		{x =  0, y =  0, z = -1};
	};






	planecorners = {
		{x =  1, y =  0, z =  1};
		{x = -1, y =  0, z =  1};
		{x = -1, y =  0, z = -1};
		{x =  1, y =  0, z = -1};

		{x =  1, y =  1, z =  0};
................................................................................
		end
		checked[#checked+1] = pos
		i = i + 1
	until i > #stack
	return nodes, positions
end;















return {
	offsets = ofs;
	purge_container = function(...) return purge_container(nil, ...) end;
	purge_only = function(lst)
		return function(...)
			return purge_container(lst, ...)
		end
	end; 

	is_air = function(pos)
		local n = force(pos)
		if n.name == 'air' then return true end
		local d = minetest.registered_nodes[n.name]
		if not d then return false end
		return (d.walkable == false) and (d.drawtype == 'airlike' or d.buildable_to == true)
	end;

	is_clear = function(pos)
		if not sorcery.lib.node.is_air(pos) then return false end
		local ents = minetest.get_objects_inside_radius(pos,0.5)
		if #ents > 0 then return false end
		return true
	end;

	insert = function(item, slot, npos, user, inv)
		inv = inv or minetest.get_meta(npos):get_inventory()
		if inv:room_for_item(slot,item) then
			inv:add_item(slot,item)
		else repeat
			if user then
................................................................................
					ui:add_item('main', item)
					break
				end
			end
			minetest.add_item(npos, item)
		until true end
	end;

















	tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
		-- this is going to require some explanation.
		--
		-- for various purposes, we want to be able to tell the difference between
		-- a tree that has grown naturally from the grown vs. a couple of trunk nodes
		-- that the player has jammed together, even if she's built her own counterfeit
................................................................................
		-- or inserting it also when it comes into contact with another trunk node,
		-- but pepole use these things to build with and that is just way way too many
		-- meta keys for me to consider it an option.
		--
		-- verdict: not very good, but decent enough for most cases. mtg should have
		--          done better than this, but now we're all stuck with their bullshit
		--
		--  UPDATE: in pratice this is way too expensive to be functional, and causes servers to hang. we're replacing it with a simpler version


		local treetype = force(pos).name
		if minetest.get_item_group(treetype, 'tree') == 0 then -- sir this is not a tree
			return nil -- 無
		end
		local treedef = sorcery.lib.tbl.select(sorcery.data.trees, function(ent)
			return sorcery.lib.tbl.strmatch(ent.node, treetype)







>
>
>
>
>
>







 







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









|
<
<
<
<
<
<
<
|
<
<
<
<
<







 







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







 







|
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
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
...
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
...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
		{x =  0, y =  1, z =  0};
		{x =  0, y = -1, z =  0};
		{x =  1, y =  0, z =  0};
		{x = -1, y =  0, z =  0};
		{x =  0, y =  0, z =  1};
		{x =  0, y =  0, z = -1};
	};
	corners = {
		{x =  1, y =  0, z =  1};
		{x = -1, y =  0, z =  1};
		{x = -1, y =  0, z = -1};
		{x =  1, y =  0, z = -1};
	};
	planecorners = {
		{x =  1, y =  0, z =  1};
		{x = -1, y =  0, z =  1};
		{x = -1, y =  0, z = -1};
		{x =  1, y =  0, z = -1};

		{x =  1, y =  1, z =  0};
................................................................................
		end
		checked[#checked+1] = pos
		i = i + 1
	until i > #stack
	return nodes, positions
end;

local is_air = function(pos)
	local n = force(pos)
	if n.name == 'air' then return true end
	local d = minetest.registered_nodes[n.name]
	if not d then return false end
	return (d.walkable == false) and (d.drawtype == 'airlike' or d.buildable_to == true)
end;

local is_clear = function(pos)
	if not sorcery.lib.node.is_air(pos) then return false end
	local ents = minetest.get_objects_inside_radius(pos,0.5)
	if #ents > 0 then return false end
	return true
end;
return {
	offsets = ofs;
	purge_container = function(...) return purge_container(nil, ...) end;
	purge_only = function(lst)
		return function(...)
			return purge_container(lst, ...)
		end
	end; 

	is_air = is_air;







	is_clear = is_clear;






	insert = function(item, slot, npos, user, inv)
		inv = inv or minetest.get_meta(npos):get_inventory()
		if inv:room_for_item(slot,item) then
			inv:add_item(slot,item)
		else repeat
			if user then
................................................................................
					ui:add_item('main', item)
					break
				end
			end
			minetest.add_item(npos, item)
		until true end
	end;

	install_bed = function(bed, where, dir)
		local bottom = bed .. '_bottom'
		local top = bed .. '_top'
		local d
		if type(dir) == 'number' then
			d = dir
			dir = minetest.facedir_to_dir(d)
		else
			d = minetest.dir_to_facedir(dir)
		end
		if not is_clear(where) and is_clear(where - dir) then return false end
		minetest.set_node(where,       {name = top, param2 = d})
		minetest.set_node(where - dir, {name = bottom, param2 = d})
		return true
	end;

	tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
		-- this is going to require some explanation.
		--
		-- for various purposes, we want to be able to tell the difference between
		-- a tree that has grown naturally from the grown vs. a couple of trunk nodes
		-- that the player has jammed together, even if she's built her own counterfeit
................................................................................
		-- or inserting it also when it comes into contact with another trunk node,
		-- but pepole use these things to build with and that is just way way too many
		-- meta keys for me to consider it an option.
		--
		-- verdict: not very good, but decent enough for most cases. mtg should have
		--          done better than this, but now we're all stuck with their bullshit
		--
		--  UPDATE: in practice this was way too expensive to be functional, and causes
		--          servers to hang. ripped it out and replaced it with a simpler version

		local treetype = force(pos).name
		if minetest.get_item_group(treetype, 'tree') == 0 then -- sir this is not a tree
			return nil -- 無
		end
		local treedef = sorcery.lib.tbl.select(sorcery.data.trees, function(ent)
			return sorcery.lib.tbl.strmatch(ent.node, treetype)

Modified recipes.lua from [d8acf55fed] to [7c1490fa06].

487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
	{'sorcery:cobalt_ingot','sorcery:inversion_matrix','sorcery:cobalt_ingot'};
	{'default:bronze_ingot','sorcery:platinum_ingot','default:bronze_ingot'};
},1,{
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
})

regtech('conduction_plate', 'Conduction Plate', {metal = 1}, {
	{'','sorcery:disc_copper',''};
	{'','stairs:slab_stone',''};
	{'basic_materials:copper_wire','basic_materials:steel_bar','basic_materials:copper_wire'};
}, 1, {
	{'basic_materials:copper_wire', 'basic_materials:empty_spool'};
	{'basic_materials:copper_wire', 'basic_materials:empty_spool'};







|







487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
	{'sorcery:cobalt_ingot','sorcery:inversion_matrix','sorcery:cobalt_ingot'};
	{'default:bronze_ingot','sorcery:platinum_ingot','default:bronze_ingot'};
},1,{
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
	{'basic_materials:silver_wire', 'basic_materials:empty_spool'};
})
regtech('axial_dispulsor', 'Axial Dispulsor',{metal=1})
regtech('conduction_plate', 'Conduction Plate', {metal = 1}, {
	{'','sorcery:disc_copper',''};
	{'','stairs:slab_stone',''};
	{'basic_materials:copper_wire','basic_materials:steel_bar','basic_materials:copper_wire'};
}, 1, {
	{'basic_materials:copper_wire', 'basic_materials:empty_spool'};
	{'basic_materials:copper_wire', 'basic_materials:empty_spool'};