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   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);

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

     4      4   		{x =  0, y =  1, z =  0};
     5      5   		{x =  0, y = -1, z =  0};
     6      6   		{x =  1, y =  0, z =  0};
     7      7   		{x = -1, y =  0, z =  0};
     8      8   		{x =  0, y =  0, z =  1};
     9      9   		{x =  0, y =  0, z = -1};
    10     10   	};
           11  +	corners = {
           12  +		{x =  1, y =  0, z =  1};
           13  +		{x = -1, y =  0, z =  1};
           14  +		{x = -1, y =  0, z = -1};
           15  +		{x =  1, y =  0, z = -1};
           16  +	};
    11     17   	planecorners = {
    12     18   		{x =  1, y =  0, z =  1};
    13     19   		{x = -1, y =  0, z =  1};
    14     20   		{x = -1, y =  0, z = -1};
    15     21   		{x =  1, y =  0, z = -1};
    16     22   
    17     23   		{x =  1, y =  1, z =  0};
................................................................................
   113    119   		end
   114    120   		checked[#checked+1] = pos
   115    121   		i = i + 1
   116    122   	until i > #stack
   117    123   	return nodes, positions
   118    124   end;
   119    125   
          126  +local is_air = function(pos)
          127  +	local n = force(pos)
          128  +	if n.name == 'air' then return true end
          129  +	local d = minetest.registered_nodes[n.name]
          130  +	if not d then return false end
          131  +	return (d.walkable == false) and (d.drawtype == 'airlike' or d.buildable_to == true)
          132  +end;
          133  +
          134  +local is_clear = function(pos)
          135  +	if not sorcery.lib.node.is_air(pos) then return false end
          136  +	local ents = minetest.get_objects_inside_radius(pos,0.5)
          137  +	if #ents > 0 then return false end
          138  +	return true
          139  +end;
   120    140   return {
   121    141   	offsets = ofs;
   122    142   	purge_container = function(...) return purge_container(nil, ...) end;
   123    143   	purge_only = function(lst)
   124    144   		return function(...)
   125    145   			return purge_container(lst, ...)
   126    146   		end
   127    147   	end; 
   128    148   
   129         -	is_air = function(pos)
   130         -		local n = force(pos)
   131         -		if n.name == 'air' then return true end
   132         -		local d = minetest.registered_nodes[n.name]
   133         -		if not d then return false end
   134         -		return (d.walkable == false) and (d.drawtype == 'airlike' or d.buildable_to == true)
   135         -	end;
   136         -
   137         -	is_clear = function(pos)
   138         -		if not sorcery.lib.node.is_air(pos) then return false end
   139         -		local ents = minetest.get_objects_inside_radius(pos,0.5)
   140         -		if #ents > 0 then return false end
   141         -		return true
   142         -	end;
          149  +	is_air = is_air;
          150  +	is_clear = is_clear;
   143    151   
   144    152   	insert = function(item, slot, npos, user, inv)
   145    153   		inv = inv or minetest.get_meta(npos):get_inventory()
   146    154   		if inv:room_for_item(slot,item) then
   147    155   			inv:add_item(slot,item)
   148    156   		else repeat
   149    157   			if user then
................................................................................
   152    160   					ui:add_item('main', item)
   153    161   					break
   154    162   				end
   155    163   			end
   156    164   			minetest.add_item(npos, item)
   157    165   		until true end
   158    166   	end;
          167  +
          168  +	install_bed = function(bed, where, dir)
          169  +		local bottom = bed .. '_bottom'
          170  +		local top = bed .. '_top'
          171  +		local d
          172  +		if type(dir) == 'number' then
          173  +			d = dir
          174  +			dir = minetest.facedir_to_dir(d)
          175  +		else
          176  +			d = minetest.dir_to_facedir(dir)
          177  +		end
          178  +		if not is_clear(where) and is_clear(where - dir) then return false end
          179  +		minetest.set_node(where,       {name = top, param2 = d})
          180  +		minetest.set_node(where - dir, {name = bottom, param2 = d})
          181  +		return true
          182  +	end;
   159    183   
   160    184   	tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
   161    185   		-- this is going to require some explanation.
   162    186   		--
   163    187   		-- for various purposes, we want to be able to tell the difference between
   164    188   		-- a tree that has grown naturally from the grown vs. a couple of trunk nodes
   165    189   		-- that the player has jammed together, even if she's built her own counterfeit
................................................................................
   211    235   		-- or inserting it also when it comes into contact with another trunk node,
   212    236   		-- but pepole use these things to build with and that is just way way too many
   213    237   		-- meta keys for me to consider it an option.
   214    238   		--
   215    239   		-- verdict: not very good, but decent enough for most cases. mtg should have
   216    240   		--          done better than this, but now we're all stuck with their bullshit
   217    241   		--
   218         -		--  UPDATE: in pratice this is way too expensive to be functional, and causes servers to hang. we're replacing it with a simpler version
          242  +		--  UPDATE: in practice this was way too expensive to be functional, and causes
          243  +		--          servers to hang. ripped it out and replaced it with a simpler version
   219    244   
   220    245   		local treetype = force(pos).name
   221    246   		if minetest.get_item_group(treetype, 'tree') == 0 then -- sir this is not a tree
   222    247   			return nil -- 無
   223    248   		end
   224    249   		local treedef = sorcery.lib.tbl.select(sorcery.data.trees, function(ent)
   225    250   			return sorcery.lib.tbl.strmatch(ent.node, treetype)

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

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