Modding Type change and save loading -> ctd

This subforum contains all the issues which we already resolved.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Modding Type change and save loading -> ctd

Post by FreeER »

tried to load an older save and got an error

Code: Select all

entity rubber-tree saved as type tree, but now it is type container
pressing ok closes factorio.
First it should simply return to the save list, second is there a way to delete or change the saved entity type (migrations maybe)? I'm not worried about the save since it is an older one, but it could be an issue later lol :)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by kovarex »

The current migration mechanism doesn't allow to migrate between different entity types.
We could provide way to do it, but there would be some limitations. (In other words, settings of the machine would be lost, and it would be just replaced by new created entity of the new type).
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

that would at least allow saves to be recovered :)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Modding Type change and save loading -> ctd

Post by Dysoch »

FreeER wrote:tried to load an older save and got an error

Code: Select all

entity rubber-tree saved as type tree, but now it is type container
pressing ok closes factorio.
First it should simply return to the save list, second is there a way to delete or change the saved entity type (migrations maybe)? I'm not worried about the save since it is an older one, but it could be an issue later lol :)
I think thath is my mod ;) but i wonder, did you change the rubber tree to tree type? I never did actually (well i did, but never released it) because it simply gives an error when its type tree because of the inventory size it has. So even if it loaded, it probably gave an error after loading your save.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

Dysoch wrote:I think thath is my mod ;) but i wonder, did you change the rubber tree to tree type? I never did actually (well i did, but never released it) because it simply gives an error when its type tree because of the inventory size it has. So even if it loaded, it probably gave an error after loading your save.
It was when I was testing autoplace for your tree :) more specifically why the trees were red...somehow it got saved and I didn't know it until now lol. So like I'd said, not an issue now and I imagine most authors would simply let people know they needed a new save to update, but when we finally get the ability to add our own entity types I see this being an issue lol.

off topic: hmm, I should google dlls more and see if it would be possible for people that know c++ to create dlls that specify the type data for factorio to load prior to loading lua mods... :cry: I just don't have the experience that I wish I did.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by kovarex »

FreeER wrote:off topic: hmm, I should google dlls more and see if it would be possible for people that know c++ to create dlls that specify the type data for factorio to load prior to loading lua mods... :cry: I just don't have the experience that I wish I did.
I'm not sure what do you mean by this.

Anyway I just commited change, that makes the migration between different types possible.
In the case the migrated type of entity is different than the existing, the new entity inherits just position, force and direction and the old one is thrown away, I made a test migration that replaced big tree with wooden chest and it worked well (and was looking funny as well^^), so this will be available in 0.8.

Note, that just changing the type isn't possible, the modder needs to change the type AND the name of the entity and make migration, but it is not so hard to do.
Attachments
wooden-chest-forest.png
wooden-chest-forest.png (640.56 KiB) Viewed 4871 times
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

kovarex wrote:
FreeER wrote:off topic: hmm, I should google dlls more and see if it would be possible for people that know c++ to create dlls that specify the type data for factorio to load prior to loading lua mods... :cry: I just don't have the experience that I wish I did.
I'm not sure what do you mean by this.
like a regular player (who knows c++) creating the entity header/source c++ code using an api that you guys make public and then compiling that as a dll (not sure if dll is a generic term so: Dynamically Linked Library, I think linux/mac may call it an 'so', shared object file or simply a library). Factorio would load that and it would then be available for lua mods to access (just like the other types, car/character/market/etc). The only programs I can think of off the top of my head that load user created plugins/mods is olly debug (win32 debugging program) and winamp, and I guess browsers like firefox (though how much of that is changing the program...idk)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by kovarex »

FreeER wrote:
kovarex wrote:
FreeER wrote:off topic: hmm, I should google dlls more and see if it would be possible for people that know c++ to create dlls that specify the type data for factorio to load prior to loading lua mods... :cry: I just don't have the experience that I wish I did.
I'm not sure what do you mean by this.
like a regular player (who knows c++) creating the entity header/source c++ code using an api that you guys make public and then compiling that as a dll (not sure if dll is a generic term so: Dynamically Linked Library, I think linux/mac may call it an 'so', shared object file or simply a library). Factorio would load that and it would then be available for lua mods to access (just like the other types, car/character/market/etc). The only programs I can think of off the top of my head that load user created plugins/mods is olly debug (win32 debugging program) and winamp, and I guess browsers like firefox (though how much of that is changing the program...idk)
Yes, I used olly debug a lot while creating bwapi ... these are nice memories :)

Anyway I had idea like this, but it has problems:
  • Different OS, you would either have to distribute the binary to all of the OS or distribute source codes, and the source would have to be compiled during start.
  • Security, how would you make sure, that the code won't do something nasty, it is very hard, almost impossible to do (unlike lua)
  • It would require lot of effort to make the C++ api usable without going all open source.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

kovarex wrote:Anyway I had idea like this, but it has problems:

Different OS, you would either have to distribute the binary to all of the OS or distribute source codes, and the source would have to be compiled during start.
Security, how would you make sure, that the code won't do something nasty, it is very hard, almost impossible to do (unlike lua)
It would require lot of effort to make the C++ api usable without going all open source.
everything has problems, that's what half of what programming is about (solving them lol).
  • 1 I knew, I would think it would be possible to find someone to compile the source for each OS (I could compile on windows and probably linux if I tried, but I'd need someone to compile mac.) so i don't think this is a huge issue, especially with the current number of people.
  • 2 I didn't really think about this too much, I thought maybe there could be a peer review section for the c++ code but I'm not sure exactly how viable that is, especially with a larger community.
  • as for 3, I simply don't have enough experience to say know anything about. :)
But as long as you've thought about it then I don't need to worry any, you know better than I do how it could work and why it wouldn't :D
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by SilverWarior »

As far as I know it is posible to save specififc classes in their own DLL's.
So modders could actually make custom classes for ingame objects. This could even alow making mods without the use of any LUA scripting in the first place. Another advantage of this would be the ability to actually compile theese DLL's with other programming languages and not only C++.

For this to work you should define some kind of a interface standard through which game will comunicate with DLL.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

SilverWarior wrote:As far as I know it is posible to save specififc classes in their own DLL's.
That's why I asked, I don't know much but as far as I know this is true lol
So modders could actually make custom classes for ingame objects. This could even alow making mods without the use of any LUA scripting in the first place.
True, but it would probably be best if these were used exclusively for what cannot be done with lua. That way the custom classes can be used by anyone/everyone without having to learn a complex (and strict) language, say someone creates a aircraft mod with the api, no one else would be able to use the aircraft entity without having the entire mod. Coding only the entity (and other required classes etc) and then using lua for the rest of the mod allows other people to use that aircraft for their own purposes. I'd think this would also make the api and dll programming easier
Another advantage of this would be the ability to actually compile theese DLL's with other programming languages and not only C++.
would this not require either forcing a c style api (most languages seem to have a way to interact with c already) or multiple apis?
For this to work you should define some kind of a interface standard through which game will comunicate with DLL.
I believe that is part of what his third point was about
kovarex wrote:It would require lot of effort to make the C++ api usable without going all open source.
edit: if this question/discussion goes on much more it should probably be moved into Code Base or Modding Interface Requests. It was off topic to begin with and this bug has been resolved.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by kovarex »

SilverWarior wrote:As far as I know it is posible to save specififc classes in their own DLL's.
So modders could actually make custom classes for ingame objects. This could even alow making mods without the use of any LUA scripting in the first place. Another advantage of this would be the ability to actually compile theese DLL's with other programming languages and not only C++.

For this to work you should define some kind of a interface standard through which game will comunicate with DLL.
Yes, but the security is still an issue, with just lua base mods, you can just set the game to automatically update/download all the mods needed when playing games without worry.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by FreeER »

auto update/download mods? isn't that a bit farther off yet? If you did set up a mod gallery of sorts (mentioned in an email awhile back) then you could just as easily delay the update/download until it had been verified as safe. As for direct connection with the host's mods being downloaded by anyone connecting...first it would only work on same os (hosts would need dll for every os they expect to play, or compile on run as mentioned earlier) and second most people would only play with people they knew (lans or people they are willing to give their IP to), once you have a lobby-type thing, then again, you could have a list of verified c++ mods/extensions and only those are auto-downloaded, or you could even disallow non verified libraries in public games.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Modding Type change and save loading -> ctd

Post by kovarex »

Anyway, as it is now possible to change the item type, so I move it to resolved problems.
When someone just changes the type without the migration, it still crashes, but the nice way (with message and explanation).
Post Reply

Return to “Resolved Problems and Bugs”