Differences From
Artifact [27c07e8c34]:
1158 1158 end
1159 1159 if next(a) then
1160 1160 table.insert(ary, a)
1161 1161 return true
1162 1162 end
1163 1163 return false
1164 1164 end
1165 + local daytime = minetest.get_natural_light(ctr:offset(0,1,0)) > 9
1165 1166 for name,tree in pairs(sorcery.data.trees) do
1166 1167 try(materials.corners, tree.node)
1167 1168 try(materials.walls, tree.plank)
1168 1169 try(materials.floor, tree.plank)
1169 1170 end
1170 1171 try(materials.roof, 'farming:straw')
1171 1172 try(materials.floor, 'farming:straw')
................................................................................
1196 1197 try(materials.corners, 'default:desert_sandstone_brick')
1197 1198 try(materials.corners, 'default:silver_sandstone_brick')
1198 1199 if math.random(1,10) == 7 then
1199 1200 try(materials.corners, 'default:obsidianbrick')
1200 1201 end
1201 1202
1202 1203 try(materials.lamp_wall, 'default:torch_wall')
1203 - try(materials.lamp_wall, 'morelights_modern:wall_lamp')
1204 + try(materials.lamp_wall, 'morelights_modern:walllamp')
1204 1205
1205 - try(materials.lamp_ext, 'default:torch')
1206 - try(materials.lamp_ext, 'morelights_modern:wall_lamp')
1207 - try(materials.lamp_ext, 'morelights_modern:lantern_f')
1206 + try(materials.lamp_ext, 'default:torch_wall')
1207 + try(materials.lamp_ext, 'morelights_modern:walllamp')
1208 + try(materials.lamp_ext, 'morelights_vintage:lantern_w')
1208 1209
1209 1210 for _, l in pairs {
1210 1211 'default:meselamp';
1211 1212 'morelights_modern:barlight_s';
1212 1213 'morelights_modern:ceilinglight';
1213 1214 'morelights_modern:canlight_d';
1214 1215 'morelights_modern:canlight_l';
................................................................................
1332 1333 minetest.set_node(ctr:offset( dim.rx,y,z), {name=mpick'walls'})
1333 1334 end
1334 1335 end
1335 1336 i=i+1
1336 1337 end
1337 1338 local t_built = per*i
1338 1339 local lighting = math.random(1,2)
1340 + local put_align = function(where,node,dir)
1341 + local dfn = function() return 0 end
1342 + local pt2 = minetest.registered_nodes[node].paramtype2
1343 + if pt2 == 'facedir' or pt2 == 'wallmounted' then
1344 + dfn = minetest['dir_to_' .. pt2]
1345 + end
1346 + minetest.set_node(where, { name=node, param2=dfn(dir) })
1347 + end
1339 1348 if lighting == 1 then
1340 1349 local lh = math.ceil(dim.y * .6)
1341 1350 local wlamps = {
1342 1351 ctr:offset( dim.rx - 1 , lh,0);
1343 1352 ctr:offset(-(dim.rx - 1), lh,0);
1344 1353 ctr:offset(0, lh, dim.rz - 1);
1345 1354 ctr:offset(0, lh, -(dim.rz - 1));
................................................................................
1347 1356 sorcery.lib.tbl.shuffle(wlamps)
1348 1357 for _, where in pairs(wlamps) do
1349 1358 i = i + 10
1350 1359 timeline[{whence=0, secs = per*i}] = function(s)
1351 1360 spark(s,where)
1352 1361 local node = select(2,sorcery.lib.tbl.pick(materials.lamp_wall))
1353 1362 minetest.sound_play('sorcery_put',{pos=where,gain=0.8},true)
1354 - minetest.set_node(where, {
1355 - name=node;
1356 - param2=minetest.dir_to_wallmounted(vector.normalize(ctr:offset(0,lh,0) - where)*-1);
1357 - })
1363 + put_align(where, node, vector.normalize(ctr:offset(0,lh,0) - where)*-1)
1358 1364 end
1359 1365 end i=i+1
1360 1366 elseif lighting == 2 then
1361 1367 local which = math.random(1,3)
1362 1368 if which == 1 or which == 2 then
1363 1369 i = i + 20
1364 1370 timeline[{whence=0, secs = per*i}] = function(s)
................................................................................
1388 1394 minetest.sound_play('sorcery_put',{pos=v,gain=0.7},true)
1389 1395 minetest.set_node(v, {name = node})
1390 1396 end
1391 1397 i = i + 7
1392 1398 end
1393 1399 end
1394 1400 end
1395 - -- install door
1401 +
1402 + -- cut out door
1396 1403 local doorside = ({
1397 1404 vector.new( dim.rx,1,0);
1398 1405 vector.new(0,1, dim.rz);
1399 1406 vector.new(-dim.rx,1,0);
1400 1407 vector.new(0,1,-dim.rz);
1401 1408 })[math.random(1,4)]
1409 + local doorslideaxis = doorside.z ~= 0 and 'x' or 'z'
1402 1410 local doorpos
1403 1411 if math.random(1,3) == 1 then
1404 - if doorside.z ~= 0 then
1405 - doorside.x = doorside.x + math.random(-(dim.rx-1), dim.rx-1)
1406 - elseif doorside.x ~= 0 then
1407 - doorside.z = doorside.z + math.random(-(dim.rz-1), dim.rz-1)
1408 - end
1412 + local d = dim['r'..doorslideaxis] - 1
1413 + doorside[doorslideaxis] = doorside[doorslideaxis] + math.random(-d,d)
1409 1414 end
1410 1415 doorpos = ctr + doorside
1411 1416 local door = mpick'door'
1412 1417 i=i+5
1413 1418 timeline[{whence=0,secs=per*i}] = function(s)
1414 1419 minetest.remove_node(doorpos)
1415 1420 minetest.remove_node(doorpos:offset(0,1,0))
................................................................................
1420 1425 -- local d = ItemStack(door)
1421 1426 -- d:get_definition().on_place(d, s.caster, {
1422 1427 -- type = 'node';
1423 1428 -- above = doorpos;
1424 1429 -- under = doorpos:offset(0,-1,0);
1425 1430 -- })
1426 1431 end
1432 +
1433 + -- install outdoor lighting
1434 + if math.random(1,7) == 1 or not daytime then
1435 + local xwall,xspc = dim.rx, dim.rx+1
1436 + local zwall,zspc = dim.rz, dim.rz+1
1437 + local lh = dim.y - 1
1438 + for _, o in pairs(sorcery.lib.node.offsets.corners) do
1439 + local w = ctr:add {
1440 + z = dim.rz * o.z;
1441 + x = dim.rx * o.x;
1442 + y = lh;
1443 + }
1444 + local put = function(ofs)
1445 + timeline[{whence=0,secs=per*i}] = function(s)
1446 + local p = vector.add(w,ofs)
1447 + if not sorcery.lib.node.is_clear(p) then return end
1448 + spark(s, p)
1449 + minetest.sound_play('sorcery_put', {pos = p, gain = 0.4}, true)
1450 + local lamp = mpick 'lamp_ext'
1451 + print('installing lamp',lamp,p,vector.new(ofs))
1452 + put_align(p, lamp, vector.multiply(ofs,-1))
1453 + end
1454 + i=i+1
1455 + end
1456 + put{x=o.x, y=0, z=0}
1457 + put{x=0, y=0, z=o.z}
1458 + end
1459 + end
1460 +
1461 + -- lay down bed
1462 + i=i+3
1463 + timeline[{whence=0,secs=per*i}] = function(s)
1464 + local bed = 'beds:bed'
1465 + if math.random(1,3) == 1 then bed = 'beds:fancy_bed' end
1466 + local top = ctr:offset(dim.rx-1,1,dim.rz-1)
1467 + sorcery.lib.node.install_bed(bed, top, vector.new(1,0,0))
1468 + spark(s, top)
1469 + spark(s, top:offset(-1,0,0))
1470 + minetest.sound_play('sorcery_put', {pos = doorpos, gain = 0.9}, true)
1471 + end
1427 1472
1428 1473 sorcery.spell.cast {
1429 1474 name = 'sorcery:shelter';
1430 1475 groups = {'genesis','construct'};
1431 1476 caster = ctx.caster;
1432 1477 anchor = ctr;
1433 1478 radius = math.max(dim.rz, dim.rx);