Rotate an image in a sprite

Place to get help with not working mods / modding interface.
Post Reply
sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Rotate an image in a sprite

Post by sore68 »

Hi~

I want to create a mode that gives direction.(ore compass)
I'm going to draw an arrow on the gui and the ground.

Do sprite have a command to rotate the image at a free angle? or need to register images in all directions?

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Rotate an image in a sprite

Post by Nexela »

Create your sprite sheet filled with all of your arrows. Starting from North to East to West to South (and any in-betweens)

Create a car type entity, assign it to your sprite. When creating the entity/sprite set the .orientation to the direction you want. (depending on the number of frames you might need to adjust/compare to a range)
animation portion
for an example see the nixie_tubes mod

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Rotate an image in a sprite

Post by Yoyobuae »

Nexela wrote:Create a car type entity, assign it to your sprite.
I was wondering: Is abusing entity types the only way to display custom arrows/graphics like this? Seems awfully wasteful to create an entity just to display an arrow. :?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Rotate an image in a sprite

Post by DaveMcW »

Yoyobuae wrote:Seems awfully wasteful to create an entity just to display an arrow. :?
It's even more wasteful to support every property on every entity. The mod system encourages you to find an entity similar to what you want and hack it.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Rotate an image in a sprite

Post by Yoyobuae »

DaveMcW wrote:
Yoyobuae wrote:Seems awfully wasteful to create an entity just to display an arrow. :?
It's even more wasteful to support every property on every entity. The mod system encourages you to find an entity similar to what you want and hack it.
Problem is that there's so many things tied to entity type. Only way to mix-and-match features from various entity types is to spawn multiple hidden entities. And then the mod needs to manage the lifetimes of those entities. Feels like really weird and hacky way of doing things. I would prefer to have some flags to tell the entity what sort of properties to implement.

Anyway, I was just wondering if there was a better alternative. If there's not then I'll keep using what works.

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Rotate an image in a sprite

Post by daniel34 »

Yoyobuae wrote:Problem is that there's so many things tied to entity type. Only way to mix-and-match features from various entity types is to spawn multiple hidden entities. And then the mod needs to manage the lifetimes of those entities. Feels like really weird and hacky way of doing things. I would prefer to have some flags to tell the entity what sort of properties to implement.
[1] More flexible API / using flags
Rseding91 wrote:
Factoruser wrote:the entity concept should be changed to a flag-based system - and all entity-types should have prototypes.

I.e. you should be able to easily add e.g. electricity consumption to any new or existing entity without writing an OnTick() subroutine. Flags are something like: consumesElectricity, hasInputInventory, hasFuelInventory, hasStorageInventory, wireConnectable etc. The entity-type prototypes are pre-setting them, and can be overwritten by derived entity prototypes.
You've never written any large piece of performance intensive software have you? There have been multiple suggestions to do this and my response is the same to every one of them:

Until I see *anyone* else implement such a system at the scale that Factorio runs and be successful doing so it's just not even something worth thinking about.
[2] Entity Prototype Composition
Rseding91 wrote:Yeah that's not happening :)

It would require a complete re-write of the game from the ground up to *maybe* work and I have extreme doubts it could be done without a huge impact on performance and the number of bugs introduced/difficulty of debugging a given issue.
quick links: log file | graphical issues | wiki

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Rotate an image in a sprite

Post by Yoyobuae »

Yeah, I imagined there was some kind of reason for it. So I guess using multiple entities will remain the way to go then.

I only hope they keep adding more entity types which are useful for modding, like the electric-energy-interface one.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1195
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Rotate an image in a sprite

Post by Mooncat »

TBH the first quote made me feel that Rseding doesn't want to be the first one to invent a great system. It is like "I will consider replicating the system if one exists". It doesn't sound right.
But I respect what he has done and I understand he is busy.
Yoyobuae wrote:I only hope they keep adding more entity types which are useful for modding, like the electric-energy-interface one.
Please add an entry in the Modding Interface Requests forum if you have a good idea. ;)

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: Rotate an image in a sprite

Post by sore68 »

Oh! Thank you for posts :D

I decided to make eight arrows.
I did not understand the diagonal and curves of the rails...(+Curved rails make eight in two sets.)

Post Reply

Return to “Modding help”