Hi, I have an idea for a mod and I would like to scout if it is technical possible.
What I want to do is to pay for the kill of each biter or nest. Money can be items or some virtual numbers.
Money as an item:
When a biter is killed an amount of money-items is deleted.
Money as virtual number:
When a biter is killed the virtual number will be reduced.
As money making:
Items from a factory
Virtual number increasing when factory is running
What do you think, how can it be implemented? Or maybe there are some parts from other modes to reuse. Or an other way to do this.
Delete items on biters death
Re: Delete items on biters death
Found so far this event: onentitydied.
Cause there is only one primer cause of death for biters I think it will be enough to check if a biter was killed.
Still looking who to delete an time/items on at this event... Would be cool if someone had an example with onentitydied...
Cause there is only one primer cause of death for biters I think it will be enough to check if a biter was killed.
Still looking who to delete an time/items on at this event... Would be cool if someone had an example with onentitydied...
Re: Delete items on biters death
Code: Select all
game.onevent(defines.events.onentitydied, function(event)
elseif event.entity.force.name == "enemy" then
local cant = math.floor(event.entity.prototype.maxhealth * 0.1) -- math.floor round the number from 0 to 0.9 is 0.
if cant > 0 then
game.player.insert({name="money",count=cant})
end
end
end)
Re: Delete items on biters death
I used this as test and it works! Thanks you
Code: Select all
game.onevent(defines.events.onentitydied, function(event)
game.onevent(defines.events.onentitydied, function(event)
--game.showmessagedialog{text = {"msg-someone-dead"}}
if event.entity.type == "unit" then
game.player.insert({name="iron-ore",count=1})
--player.character.insert ({name="iron-ore",count=1})
game.player.print({"msg-bist-dead"})
else
game.player.print({"msg-someone-dead"})
end
end)