Looking for examples of adding icons on top of player characters or enemies
Looking for examples of adding icons on top of player characters or enemies
I'd like to add icons on top of the things that move, but their definitions are somewhat complex, so it'd be very useful to have an example of how it could be done.
Re: Looking for examples of adding icons on top of player characters or enemies
Code: Select all
events.on_event(defines.events.on_tick,function()
for k,ent in pairs(ENTITIES_WE_WANT_SPRITES_TO_FOLLOW)do
for i,sprite in pairs(global.sprite_cache[ent.unit_number])do
rendering.set_position(sprite,ent.position)
end
end
end)
Re: Looking for examples of adding icons on top of player characters or enemies
Without usage of on_tick, the sprite will follow the target around:
Code: Select all
/c rendering.draw_sprite{sprite="item.iron-plate", target = game.player.character, target_offset = {0,-2}, surface = game.player.surface}
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.