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.
More flexible API / using flags
Moderator: ickputzdirwech
-
- Fast Inserter
- Posts: 167
- Joined: Tue Sep 16, 2014 5:48 pm
- Contact:
Re: More flexible API / using flags
Would be nice. Would require ground up rewrite. Seems never to be implemented viewtopic.php?f=28&t=24064&p=151436
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
-
- Fast Inserter
- Posts: 167
- Joined: Tue Sep 16, 2014 5:48 pm
- Contact:
Re: More flexible API / using flags
Going in a similar direction... But all to do would be "just" to exchange everywhere e.g. "if (type="electric-pole")" with "if (distributesElectricity())". Never underestimate such changes of course.Adil wrote:Would be nice. Would require ground up rewrite.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: More flexible API / using flags
It's not that simple, you have to factor in branch predication and a bunch of other stuff. Having masses of if statements would dramatically slow the game down.
An alternate approach might be to group entities with similar flags, effectively creating crankenshaft-style pseudo-classes. But that's going to be huge amount of work with no guarantee of success.
An alternate approach might be to group entities with similar flags, effectively creating crankenshaft-style pseudo-classes. But that's going to be huge amount of work with no guarantee of success.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: More flexible API / using flags
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: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.
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.
If you want to get ahold of me I'm almost always on Discord.
-
- Fast Inserter
- Posts: 167
- Joined: Tue Sep 16, 2014 5:48 pm
- Contact:
Re: More flexible API / using flags
Öööhm... I've had once to deal with very limited hardware of 1 MiB RAM, 8 MHz and such stuff... But I don't know your code and how the LUA interpreter is integrated into projects. Normally, checking flags IS performant (AND gate). Especially compared to instead using an OnTick()-subroutine for each entity written in LUA Script. But if you have to rewrite nearly the whole core, it's just not worth it.Rseding91 wrote:You've never written any large piece of performance intensive software have you?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.
Re: More flexible API / using flags
I think this discussion is not useful in any direction until some game-code (C++) is known and understood.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...