From 67576287ef9ae570ec1e29f6c2300fa5d16aee92 Mon Sep 17 00:00:00 2001 From: Leslie Krause Date: Thu, 14 May 2020 18:12:17 -0400 Subject: [PATCH] Build 02 - simple fixes --- init.lua | 112 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/init.lua b/init.lua index 7c97e9c..2144e17 100644 --- a/init.lua +++ b/init.lua @@ -56,60 +56,6 @@ end -------------------- -axon.register_source = function ( node_name, stimulus_list ) - if not sources[ node_name ] then - sources[ node_name ] = { } - end - for i, v in pairs( stimulus_list ) do - local stimulus - if v.class == "contact" then - stimulus = ContactStimulus( node_name, v.group, v.intensity, v.chance, v.period, v.power ) - elseif v.class == "radiation" then - stimulus = RadiationStimulus( node_name, v.group, v.intensity, v.chance, v.period, v.radius, v.scale, v.power, v.max_count ) - elseif v.class == "immersion" then - stimulus = ImmersionStimulus( node_name, v.group, v.intensity, v.chance, v.period ) - end - table.insert( sources[ node_name ], stimulus ) - end -end - -axon.register_source_group = function ( node_group, node_names ) - for i, v in ipairs( node_names ) do - local groups = minetest.regi stered_nodes[ v ].groups - - groups[ node_group ] = 1 - minetest.override_item( v, { groups = groups } ) - end -end - -axon.generate_direct_stimulus = function ( obj, groups ) - punch_object( obj, groups ) -end - -axon.generate_radial_stimulus = function ( pos, radius, speed, slope, chance, groups, classes ) - for obj in mobs.iterate_registry( pos, radius, radius, classes ) do - local length = vector.distance( pos, obj:get_pos( ) ) - - if length <= radius and random( chance ) == 1 then - local damage_groups = { } - - for k, v in pairs( groups ) do - damage_groups[ k ] = ceil( v * get_signal_strength( radius, radius - length, slope ) ) - end - - if speed > 0 then - minetest.after( length / speed, function ( ) - punch_object( obj, damage_groups, pos ) - end ) - else - punch_object( obj, damage_groups, pos ) - end - end - end -end - --------------------- - local function ContactStimulus( node_name, group, intensity, chance, period, power ) local self = { } @@ -134,7 +80,7 @@ local function ContactStimulus( node_name, group, intensity, chance, period, pow end return self -vend +end local function RadiationStimulus( node_name, group, intensity, chance, period, radius, scale, power, max_count ) local self = { } @@ -245,7 +191,9 @@ function AxonObject( self, armor_groups ) end self.on_step = function ( self, dtime, pos, ... ) +S1() propagator.on_step( dtime, pos ) +S1_() old_on_step( self, dtime, pos, ... ) end @@ -302,4 +250,58 @@ end -------------------- +axon.register_source = function ( node_name, stimulus_list ) + if not sources[ node_name ] then + sources[ node_name ] = { } + end + for i, v in pairs( stimulus_list ) do + local stimulus + if v.class == "contact" then + stimulus = ContactStimulus( node_name, v.group, v.intensity, v.chance, v.period, v.power ) + elseif v.class == "radiation" then + stimulus = RadiationStimulus( node_name, v.group, v.intensity, v.chance, v.period, v.radius, v.scale, v.power, v.max_count ) + elseif v.class == "immersion" then + stimulus = ImmersionStimulus( node_name, v.group, v.intensity, v.chance, v.period ) + end + table.insert( sources[ node_name ], stimulus ) + end +end + +axon.register_source_group = function ( node_group, node_names ) + for i, v in ipairs( node_names ) do + local groups = minetest.registered_nodes[ v ].groups + + groups[ node_group ] = 1 + minetest.override_item( v, { groups = groups } ) + end +end + +axon.generate_direct_stimulus = function ( obj, groups ) + punch_object( obj, groups ) +end + +axon.generate_radial_stimulus = function ( pos, radius, speed, slope, chance, groups, classes ) + for obj in mobs.iterate_registry( pos, radius, radius, classes ) do + local length = vector.distance( pos, obj:get_pos( ) ) + + if length <= radius and random( chance ) == 1 then + local damage_groups = { } + + for k, v in pairs( groups ) do + damage_groups[ k ] = ceil( v * get_signal_strength( radius, radius - length, slope ) ) + end + + if speed > 0 then + minetest.after( length / speed, function ( ) + punch_object( obj, damage_groups, pos ) + end ) + else + punch_object( obj, damage_groups, pos ) + end + end + end +end + +-------------------- + dofile( minetest.get_modpath( "axon" ) .. "/sources.lua" )