Event Requests

Things that we aren't going to implement
Post Reply
Chronicles
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Sep 06, 2014 2:53 am
Contact:

Event Requests

Post by Chronicles »

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.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Event Requests

Post by Adil »

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

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"...
doesn't feel right.
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.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Event Requests

Post by Choumiko »

Adil wrote: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"...
doesn't feel right.
That's right :D Neither does

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
so i would propose
onguiopened()
onguiclosed()
returning playerindex and the entity whose gui was opened/closed

User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: Event Requests

Post by ThaPear »

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:

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
It might even allow us to return the amount of damage to apply, allowing us to mitigate the damage:

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

User avatar
morphman
Burner Inserter
Burner Inserter
Posts: 7
Joined: Thu Jan 22, 2015 10:11 am
Contact:

Re: Event Requests

Post by morphman »

Chronicles wrote:oncrafteditem - called when a assembly machine / furnace creates an entity. returns item/entity
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:onuseditem - similar to onputitem, but called by an assembly machine / furnace instead of player.
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.

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.

Post Reply

Return to “Won't implement”