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?
Re: Rotate an image in a sprite
Posted: Tue Dec 13, 2016 3:47 pm
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 =
{
layers =
{
{
width = 171, --width and height of each frame
priority="extra-high",
height = 185,
frame_count = 1,
direction_count = 30, --The number of frames in the sheet
shift = {0, 0},
animation_speed = 0.1,
max_advance = 0.2,
stripes =
{
{
---example sheet contains 10 columns and 3 rows.
filename = "__modname__/graphics/sheet_name.png",
priority="extra-high",
width_in_frames = 10,
height_in_frames = 3,
},
}
},
}
},
for an example see the nixie_tubes mod
Re: Rotate an image in a sprite
Posted: Thu Dec 15, 2016 4:58 pm
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.
Re: Rotate an image in a sprite
Posted: Thu Dec 15, 2016 6:03 pm
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.
Re: Rotate an image in a sprite
Posted: Thu Dec 15, 2016 6:49 pm
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.
Re: Rotate an image in a sprite
Posted: Thu Dec 15, 2016 8:55 pm
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.
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.
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.
Re: Rotate an image in a sprite
Posted: Thu Dec 15, 2016 9:37 pm
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.
Re: Rotate an image in a sprite
Posted: Fri Dec 16, 2016 2:17 am
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.