Page 1 of 1

on_picked_up_item filter for only one item

Posted: Thu Apr 19, 2018 12:55 pm
by DellAquila
Hello ! I have a item named "map" and I would like it as soon as the person picks it off the floor, it executes this routine, but I can not understando how to filter to only appear when the player picks the item "map"
script.on_event(defines.events.on_picked_up_item, function(event)
local player = game.players[event.player_index]
player.force.chart(player.surface, {{player.position.x - 300, player.position.y - 300}, {player.position.x + 300, player.position.y + 300}})
if (#game.players <= 1) then
game.show_message_dialog{text = {"msg-map"}}
else
player.print({"msg-map"})
end
end)
Thanks a lot !! :D

Re: on_picked_up_item filter for only one item

Posted: Thu Apr 19, 2018 2:10 pm
by steinio

Code: Select all

if event.item_stack.name == "map" then
    --do the map stuff
end

Re: on_picked_up_item filter for only one item

Posted: Thu Apr 19, 2018 3:04 pm
by DellAquila
THANKS STEINIO.. Help a lot!!!

If you can help me with something else... i cant force the belts because of the "-" in "transport-belt type.

I really don't know what to do! Thanks!!! XD
-----


for _, force in pairs (game.forces) do
force.reset_technologies()
if force.technologies["belt-speed-1"].researched == true then

force.["transport-belt"]["transport-belt"].speed = 0.0375
or
force.transport-belt["transport-belt"].speed = 0.0375
or
force.entity.["transport-belt"]["transport-belt"].speed = 0.0375

end
end


all shows error

Re: on_picked_up_item filter for only one item

Posted: Thu Apr 19, 2018 3:22 pm
by steinio
Oh well i fear the speed value isn't changeable after game start.
I'll look at it.

You probably need to create different belts during startup and replace the placed ones on map after research...

Edit: game.entity_prototypes is only readable but not writable so there is no chance to change the value.

Re: on_picked_up_item filter for only one item

Posted: Thu Apr 19, 2018 4:44 pm
by DellAquila
Great Steinios,
Thank you very much for your attention, it helped me a lot! So I do not keep trying these impossible things !!! Thanks!