Page 1 of 1
					
				dynamite does not set off nearby dynamite
				Posted: Sat May 25, 2013 4:06 am
				by FreeER
				
 I can not seem to figure this problem out lol Anyone care to take a look and see what's going on?
I currently have 
Code: Select all
        for k,nearbyentity in pairs(game.findentities{{event.entity.position.x-5, event.entity.position.y-5}, {event.entity.position.x+5, event.entity.position.y+5}}) do
            if nearbyentity.name == "dynamite" then for k,v in pairs(glob.dynamite) do if nearbyentity.equals(v.entity) then glob.dynamite[k].tick=glob.dynamite[k].tick-100 end end
            elseif nearbyentity.health then nearbyentity.damage(20, game.player.force)
            end
        end
 I would simply let the damage 'kill' the nearby dynamite expect that I get an error (and if I try to use die() instead of reducing the tick it just turns into an infinite error two message).
Also I noticed that the explosion is not what I expected....
edit: fixed, silly errors lol. had table.remove in two places (moved to only being in onentitydied), the explosions issue (which came from using a landmine type for the dynamite initially) was due to the createentity not being inside of the if name==dynamite block.
 
			
					
				Re: dynamite does not set off nearby dynamite
				Posted: Sun May 26, 2013 11:14 am
				by slpwnd
				I played around a little bit with the mod and changed the code your provided to work in the following way:
Code: Select all
for k,nearbyentity in pairs(game.findentities{{event.entity.position.x-5, event.entity.position.y-5}, {event.entity.position.x+5, event.entity.position.y+5}}) do
    if nearbyentity.isvalid() then
      if nearbyentity.name == "dynamite" then for k,v in pairs(glob.dynamite) do if nearbyentity.equals(v.entity) then v.entity.die() break end end
      elseif nearbyentity.health then nearbyentity.damage(20, game.player.force) end
    end
end
Seems to work fine.
Also there was a small error in the data.lua when icon for dynamite item was taken from the clone mod. 
Apart from that really nice mod:) I suppose dynamites would be super useful in the beginning of the game when you can use them to get plenty of resources without mining.