sorcery  Diff

Differences From Artifact [27c07e8c34]:

To Artifact [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);