EarendelDevelopers / factorio-mods

This is a public repository for tracking issues with Earendel's factorio mods.
19 stars 3 forks source link

GCKI and AAI Programmable Vehicles #256

Open EarendelGames opened 1 year ago

EarendelGames commented 1 year ago

Moved.

If I understand this correctly, there are 2 things that need to happen.

  1. Don't respond to movement commands if the movement destination is not the same surface as the vehicle.

  2. If the vehicle is not on the surface it is registered to (in AAI PV), then register it on the new surface.

  3. If 1 and 2 are done, then hopefully no special GCKI is required, but if it doesn't work out then here's the full request:

From: Pi-C Recipient: Earendel

Hi! While working on GCKI, I've noticed something new that we should sort out.

GCKI, allows the "owner" of a vehicle to summon it to a place near him. If the vehicle is on another surface, it will be teleported to the surface the owner is on. Now, if the vehicle was controlled by AAI and is driving in automatic mode, it will be proceed to move to the selected position -- even if it is on another surface!

I've prepared a small demo: Using the attached WIP version of GCKI, sync with and load the attached save. The player is inside a Factorissimo warehouse, the car has been assigned a far-away destination on nauvis. It has been locked, so it's not moving yet. Use "Toggle lock" on the GUI (already opened) to set it in motion. Then, use the keys (already in your cursor) and click on a spot close to you to summon the car. Watch it driving off into the void. :-)

I suppose you'd want to take action if one of your vehicles is teleported to another surface (e.g., stop it and allow the player to set a new destination) -- or perhaps even when it's teleported on the same surface. Would you be OK with listening to a custom event raised by GCKI? Then you could use this:

if remote.interfaces.GCKI and remote.interfaces.GCKI.get_custom_event_ids then
    local id = remote.call("GCKI", "get_custom_event_ids", "on_GCKI_teleported_vehicle")
        script.on_event(id, your_function)
end

Calling this event will get you these data:

{entity, old_surface, old_position, new_surface, new_position}

The surfaces are currently of the type LuaSurface, I probably should pass on the index or name instead. If you'd need any other data, just say so. Also, if you'd want to provide your own remote function that I should call, I'm open to that as well. However, I could also use the custom event for Autodrive, so if possible, I'd prefer that. :-)

GCKI_1.1.100.zip GCKI_AAI_change_surface_while_moving.zip