sorcery  admin.lua at [aece454800]

File admin.lua artifact a984f71f32 part of check-in aece454800


minetest.register_chatcommand('enchants', {
	description = 'Log information about the currently held object\'s enchantment';
	privs = { server = true };
	func = function(caller,params)
		local tool = minetest.get_player_by_name(caller):get_wielded_item()
		minetest.chat_send_player(caller, dump(sorcery.enchant.get(tool)))
		local binary = tool:get_meta():get_string('sorcery_enchantment_recs')
		local dumpout = ''
		for i=1,string.len(binary) do
			dumpout = dumpout .. string.format('%x%s',string.byte(binary,i),(i%16==0 and '\n') or ' ') 
		end
		print(dumpout)
	end;
})

minetest.register_chatcommand('leynet', {
	description = 'Dump information about the ley-net in front of you';
	privs = { debug = true };
	func = function(caller,params)
		local user = minetest.get_player_by_name(caller)
		local pos = user:get_pos()
		local dir = user:get_look_dir()
		local nodes = minetest.raycast(pos,pos + (dir*5), false, false)
		for pt in nodes do
			local node = minetest.get_node(pt.under)
			if node.name ~= 'air' then
				print('mapping',pt.under,node.name)
				local n = minetest.registered_nodes[node.name]
				if minetest.get_item_group(node.name, 'sorcery_ley_device') ~= 0 then
					local l = sorcery.ley.netcaps(pt.under, 1, nil, 0)
					print('ley netcaps for pos',pt.under,dump(l))
					minetest.chat_send_player(caller, 'ley netcaps:' .. dump({
						freepower = l.freepower;
						maxpower = l.maxpower;
						self = l.self;
						devs = l.net.devices.consume;
					}))
					break
				end
			end
		end
	end;
})


minetest.register_chatcommand('leyline', {
	description = 'See details about local ley force';
	privs = { debug = true };
	func = function(caller,params)
		local pos = minetest.get_player_by_name(caller):get_pos()
		local ley = sorcery.ley.estimate(pos)
		minetest.chat_send_player(caller, 'Leyline force ' .. tostring(ley.force) .. ' with affinities ' .. table.concat(ley.aff, ','))
	end;
})

-- minetest.register_chatcommand('hover', {
-- 	description = 'Test hover effect';
-- 	privs = { fly = true };
-- 	func = function(caller,params)
-- 		local player = minetest.get_player_by_name(caller)
-- 		late.new_effect(player, {
-- 			duration = 5;
-- 			fall = 5;
-- 			impacts = {
-- 				gravity = -0.1;
-- 			};
-- 		})
-- 	end;
-- })