Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Factorio 2.0: Compatibility of Map Server #8

Open
dirdante2 opened this issue Oct 25, 2024 · 9 comments
Open

Update for Factorio 2.0: Compatibility of Map Server #8

dirdante2 opened this issue Oct 25, 2024 · 9 comments

Comments

@dirdante2
Copy link

dirdante2 commented Oct 25, 2024

Hello

Is it possible to use the map server with Factorio version 2.0?
mayby there are some fundamental changes in the base game compared to version 1.0 that could impact compatibility.
Any plans to updates for making the map server work with Factorio 2.0 would be appreciated.

@aSemy
Copy link
Contributor

aSemy commented Oct 26, 2024

Hey, thanks for the interest! I've started playing Factorio v2.0 too, and I would really like to get this project to a more working state.

I suspect it will be easy to update. Kafkatorio doesn't depend on other Factorio mods, and doesn't use anything too advanced.

However, Kafkatorio is essentially an over-complicated tech demo. I'm not sure it's practical to use in real life. I think it'd be easier to remove Kafka and use SQLite instead. But that's a big refactor! Or maybe scrap everything and use Clusterio!

For now, I'll try updating the available tech bit-by-but. However, I don't have as much spare time to work on this any more, so I wouldn't expect any significant changes.

@aSemy
Copy link
Contributor

aSemy commented Oct 26, 2024

A new release of https://github.com/GlassBricks/typed-factorio is necessary for supporting Factorio 2.0.

GlassBricks/typed-factorio#40

@Dimava
Copy link

Dimava commented Oct 27, 2024

@aSemy I've published a release at ni typed-factorio@npm:@dimava/[email protected] you may try in meanwhile

@GlassBricks
Copy link

Psst! typed-factorio has just updated to factorio v2.0!

@aSemy
Copy link
Contributor

aSemy commented Nov 6, 2024

Thank you very much for the update @GlassBricks! I'm looking forward to working with your library again.

I've been tinkering with getting Kafkatorio up and running again, and it's hard work. A lot of my documentation and practices are very outdated or were dependent on system config I no longer have. It might be a while before I can get something working again.

While I'm here, I've been thinking about the implementation of Kafkatorio, and I'm wondering if anyone knows if there have been any changes in to Factorio's Lua API that might help? Is it easier to encode or decode arbitrary data to/from Json? Are there better ways to emit data in and out of a Factorio server than log messages? Maybe if there's a significant change it'd be easier to reimplement parts of Kafkatorio.

@GlassBricks
Copy link

GlassBricks commented Nov 7, 2024

Not new stuff, but providing some comments:

  • There's table_to_json and json_to_table util functions. In 2.0 the functions have moved from game to helpers. just be aware that an empty array serializes as {} (because lua).
  • There's also encode_string and decode_string for compression + base64.
  • You could perhaps use write_file instead of log messages to output information, and have some external program monitor the files. Could be a recipe for excessive temporary files, though.

@aSemy
Copy link
Contributor

aSemy commented Nov 9, 2024

Thanks!

IIRC write file will be called for all users, not just for the server, yeah, it would fill up everyone's machines with data. And while the server could clean up the files, there's no mod function to delete the old files.

Thinking out loud about other options...

I used to think that RCON could be an option, but iirc it wasn't performant, and didn't have a good way to identify or authenticate users.

One idea I haven't explored is programatically decoding the Factorio packets (https://github.com/Hornwitser/factorio-greyroom), then Kafkatorio could connect to a server as a regular user and access the data as a regular user.

@aSemy
Copy link
Contributor

aSemy commented Nov 9, 2024

I'm working through updating the mod to 2.0 now, and I have a question if you have the time to help @GlassBricks.

I want to get the x/y values of a MapPosition, but MapPosition is either an array or a struct. I'm not sure how to do this... It's been a while since I looked at TypeScript.

function collisionBox(collision_box: BoundingBoxStruct): MapBoundingBox {
  return {
    leftTop: Converters.entityPosition(collision_box.left_top),
    rightBottom: Converters.entityPosition(collision_box.right_bottom),
  }
}

function entityPosition(position: MapPosition): MapEntityPosition {
    return [position.x, position.y]; // ERROR TS2339: Property x does not exist on type MapPosition
                                     // ERROR TS2339: Property y does not exist on type MapPosition
}

EDIT: Ah, I had the wrong imports. I had imported the MapPosition from prototypes, not runtimes. I think it's working now...

@aSemy
Copy link
Contributor

aSemy commented Dec 4, 2024

Currently I'm blocked by the Factorio Docker instance not working

Also, by playing too much Factorio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants