Would like to have some event calls :
onmineditem - called when a mining drill or pumpjack mines something. returns item/entity
oncrafteditem - called when a assembly machine / furnace creates an entity. returns item/entity
onuseditem - similar to onputitem, but called by an assembly machine / furnace instead of player.
Event Requests
-
- Manual Inserter
- Posts: 1
- Joined: Sat Sep 06, 2014 2:53 am
- Contact:
Re: Event Requests
It's been a while since tread has begun, but I guess the suggestion is still worth a thought.
And I guess I'll just put suggestion for another couple of events here as well:
onvehicleentered
onvehicleexit
these should rise when player enters/exits vehicle. Because
doesn't feel right.
And I guess I'll just put suggestion for another couple of events here as well:
onvehicleentered
onvehicleexit
these should rise when player enters/exits vehicle. Because
Code: Select all
game.onevent(defines.events.ontick, function(event)
if game.player.character and game.player.character.vehicle and game.player.character.vehicle.name == "bomber"...
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: Event Requests
That's rightAdil wrote:Becausedoesn't feel right.Code: Select all
game.onevent(defines.events.ontick, function(event) if game.player.character and game.player.character.vehicle and game.player.character.vehicle.name == "bomber"...

Code: Select all
for pi, player in ipairs(game.players) do
if player.opened ~= nil and player.opened.valid then
if player.opened.type == "locomotive" and player.opened.train ~= nil then
....
elseif player.opened.type == "train-stop"
....
end
end
end
onguiopened()
onguiclosed()
returning playerindex and the entity whose gui was opened/closed
Re: Event Requests
I'd like to request onentitydamaged. It would be passed the entity in question, the damage dealt and the instigator.
It could even be allowed to return whether or not to actually apply the damage.
Example usage:
It might even allow us to return the amount of damage to apply, allowing us to mitigate the damage:
It could even be allowed to return whether or not to actually apply the damage.
Example usage:
Code: Select all
function onentitydamaged(target, damage, instigator)
if instigator == game.player then
if target.force == game.player.force then
return false -- Do not apply damage.
end
end
return true
end
Code: Select all
function onentitydamaged(target, damage, instigator)
if instigator == game.player then
if target.force == game.player.force then
return damage/10 -- Only apply 10% damage.
end
end
return damage
end
My mods: Red Alert Harvesters - Clean Pipes - Filtered Splitters
Re: Event Requests
For that you could call the Entity.getoutputinventory on the furnace/assembly to check for updates. If an item appears in the output inventory without one having been taken, then it has crafted one item.Chronicles wrote:oncrafteditem - called when a assembly machine / furnace creates an entity. returns item/entity
Similar, but instead check the Entity.getinventory and instead of checking if something is added without being taken away, just check if something has been taken away without new things being added.Chronicles wrote:onuseditem - similar to onputitem, but called by an assembly machine / furnace instead of player.
There are probably better ways to handle both, but you get an inventory as result from both to play around with and do pretty much whatever you want with.
Check the Wikipage for Lua/Entity for more info.