sorcery  Diff

Differences From Artifact [3c460c3a0d]:

To Artifact [fd8a9ad01c]:

  • File leylines.lua — part of check-in [96c5289a2a] at 2020-10-21 03:35:35 on branch trunk — add rune forges, runes, amulet frames, write sacrifice spell, touch up amulet graphics, enable enchantment of amulets (though spells cannot yet be cast), defuckulate syncresis core icon, unfuckitize sneaky leycalc bug that's probably been the cause of some long-standing wackiness, add item classes, add some more textures, disbungle various other asstastrophes, remove sneaky old debug code, improve library code, add utility for uploading merge requests (user: lexi, size: 26857) [annotate] [blame] [check-ins using]

    44     44   	privs = { server = true };
    45     45   	func = function(caller,params)
    46     46   		local pos = minetest.get_player_by_name(caller):get_pos()
    47     47   		local ley = sorcery.ley.estimate(pos)
    48     48   		minetest.chat_send_player(caller, 'Leyline force ' .. tostring(ley.force) .. ' with affinities ' .. table.concat(ley.aff, ','))
    49     49   	end;
    50     50   })
           51  +
           52  +sorcery.ley.chargetype = function(stack)
           53  +	if minetest.get_item_group(stack:get_name(),'sorcery_wand') ~= 0 then
           54  +		return 'wear'
           55  +	else
           56  +		local e = sorcery.enchant.get(stack)
           57  +		if e and #e.spells > 0 then
           58  +			return 'enchant'
           59  +		end
           60  +	end
           61  +	return false
           62  +end
           63  +
           64  +sorcery.ley.getcharge = function(stack)
           65  +	local chargetype = sorcery.ley.chargetype(stack)
           66  +	if not chargetype then return false end
           67  +	if chargetype == 'wear' then
           68  +		return (65535 - stack:get_wear()) / 15, 65535 / 15
           69  +	elseif chargetype == 'enchant' then
           70  +		local e = sorcery.enchant.get(stack)
           71  +		local mat = sorcery.itemclass.get(stack:get_name(), 'material')
           72  +		return e.energy, mat.data.maxenergy
           73  +	end
           74  +end
           75  +
           76  +sorcery.ley.setcharge = function(stack, charge, overcharge)
           77  +	local max = select(2, sorcery.ley.getcharge(stack))
           78  +	if not max then return false end
           79  +	if charge > max and not overcharge then charge = max end
           80  +
           81  +	local chargetype = sorcery.ley.chargetype(stack)
           82  +	if chargetype == 'wear' then
           83  +		stack:set_wear(65535 - charge * 15)
           84  +	elseif chargetype == 'enchant' then
           85  +		local e = sorcery.enchant.get(stack)
           86  +		e.energy = charge
           87  +		sorcery.enchant.set(stack,e)
           88  +	end
           89  +	return stack
           90  +end
    51     91   
    52     92   -- leyline energy can be transmitted via a conduit from a leysink. however, it cannot be stored like aetheric energy can be; leyline energy must be drawn when needed unless it is bound up in an enchantment (which simply delays its expression). leysinks provide a constant source of ley-force.
    53         --- there are two nodes for transmitting leyline energy, wires and conduits. wires transmit a limited amount of energy, but are cheap and small. conduits transmit much more, but are expensive and take up full blocks. both are composed of electrum, the carrier, and copper, which prevents the ley-force from leaking out as dangerous radiance.
           93  +-- there are two nodes for transmitting leyline energy, wires and conduits. wires transmit a limited amount of energy, but are cheap and small. conduits transmit much more, but are expensive and take up full blocks. both are composed of a carrier metal and copper, which prevents the ley-force from leaking out as dangerous radiance.
    54     94   
    55     95   minetest.register_node('sorcery:conduit', {
    56     96   	description = 'Conduit';
    57     97   	tiles = {
    58     98   		'sorcery_conduit_copper_top.png';
    59     99   		'sorcery_conduit_copper_top.png';
    60    100   		'sorcery_conduit_copper_side.png';
................................................................................
   275    315   end
   276    316   
   277    317   sorcery.ley.field_to_current = function(strength,time)
   278    318   	local ley_factor = 0.25
   279    319   	-- a ley harvester will produce this much current with
   280    320   	-- access to a full-strength leyline
   281    321   	
   282         -	return strength * ley_factor * time;
          322  +	return (strength * ley_factor) * time;
   283    323   end
   284    324   
   285    325   do -- register condenser
   286    326   	local gem = sorcery.lib.image('default_diamond_block.png')
   287    327   	local amethyst = gem:multiply(sorcery.lib.color(sorcery.data.gems.amethyst.tone))
   288    328   	local emerald = gem:multiply(sorcery.lib.color(sorcery.data.gems.emerald.tone))
   289    329   	local box = {
................................................................................
   539    579   					condset('minpower',min)
   540    580   					condset('maxpower',min)
   541    581   				else
   542    582   					condset('minpower',min)
   543    583   					condset('maxpower',max)
   544    584   				end
   545    585   			else -- power usage is simply a constant
   546         -				condset('power',p)
   547         -				condset('minpower',p)
   548         -				condset('maxpower',p)
          586  +				condset('power',p * timespan)
          587  +				condset('minpower',p * timespan)
          588  +				condset('maxpower',p * timespan)
   549    589   			end
   550    590   		else
   551    591   			local feval = function(v)
   552    592   				if type(v) == 'function' then
   553    593   					return v(pos,timespan)
   554    594   				else return v * timespan end
   555    595   			end