Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Help with a planetary cargo ships scenario - despawning and spawning?

Discussion in 'Programming Questions and Suggestions' started by Duckroll, Nov 8, 2016.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Duckroll Trainee Engineer

    Messages:
    73
    I'd like to make a scenario that involves the following, of which some I am unsure how to accomplish, highlighted in bold.

    Spawn Ships from a planetary base - Can use a pirate antenna for this, or MyAPIGateway.PrefabManager.SpawnPrefab() Thanks Digi!
    Spawn cargo into a container on the ship as it appears - Not sure how
    Set the name of the ship's beacon with the cargo type - This is a parameter in spawn prefab
    Fly the ship to another set point on the planet, say 20km away - Seems easy to figure out
    Make the ship fly at a slow speed, like 20m/s - Got Wicorel's autopilot script working for this :)
    Despawn the ship once it arrives within 100m of the target - Calling Grid.Close() does this, thanks Digi

    I'm unsure if this is even viable or if there's a close alternative to what i want. Any help would be appreciated.
     
    Last edited: Nov 13, 2016
  2. Wicorel Senior Engineer

    Messages:
    1,258
    I have an autopilot script that has speed limits.

    The rest I can't help you with.
     
  3. Seff Apprentice Engineer

    Messages:
    236
    For the first, ContainerTypes.sbc will allow you to create a loot table that you can then call for each container in a ship's prefab. However, ships spawned via pirate antenna cannot access this. You will have to place the cargo into the ship and then export it as a prefab. There is no way to generate cargo via containertypes for ships spawned from pirate antennas, they can only spawn with the cargo that was included in their prefab.

    For the second, there is no way of doing this, outside of possibly using the new visual scripting tools (I don't know enough about them yet to say, but I assume they can despawn ships using triggers).
     
    • Informative Informative x 1
  4. Duckroll Trainee Engineer

    Messages:
    73
    That would be great, can you link me?
     
  5. Wicorel Senior Engineer

    Messages:
    1,258
    http://forums.keenswh.com/threads/wico-nav-autopilot.7368637/
     
    • Informative Informative x 1
  6. Duckroll Trainee Engineer

    Messages:
    73
    Thanks, I played around with it this evening. I found that the Steam Guide was wrong at one part though. It says:

    But in the script the string it looks for is the group "Thrust Forward". Once I renamed my group to that it began to work.

    Also I couldn't make the new arguments method work, but a named block NAV: [Instructions] did fine

    Finally my beacon named NAV Status didn't get any renames, not sure why
     
  7. Wicorel Senior Engineer

    Messages:
    1,258

    Not many people use it; I think I'm the primary user and I keep adding more features.

    Actually, it will now also automatically find the 'forward' thrusters based on the orientation of the remote control block.

    "NAV Status:". needs to have the colon.

    If you have any questions or need help. please let me know.
     
  8. Duckroll Trainee Engineer

    Messages:
    73
    Hey Wicorel,

    I've found a slight problem with the autopilot - it tells you not to put the timer into it's own loop, but this causes it to stop moving when you save and load, as there is nothing to restart the programmable block.

    If I go against the advice and put the timer on a one second loop to call itself, it's fixed. But will this cause performance issues?
     
  9. Wicorel Senior Engineer

    Messages:
    1,258
    It will cause problems because the nav will re-start the navigation when the timer restarts..

    I have a 'fix' for this in my "DUMBNAV' handler that re-starts the nav on reload.

    The next problem is that it will start at the beginning of the nav commands: which might not be good.

    The best solution is to write a 'waypoint manager' that feeds waypoints one-at-a-time to the NAV and keeps track of where it is. It can then re-start nav on reload at the appropriate waypoint..

    I have this handler on my 'to-do' list, but it's not yet complete..

    If you have a need to make this work, I can shift my priorities. Do you have a blueprint/world?
     
  10. Duckroll Trainee Engineer

    Messages:
    73
    I have a session class in my mod, so in the end I rolled back the prefab and left the timer as it was (letting the programmable block manage it again), and then on load of the game I iterate through all entities, find the ships with the autopilot and call "Start" on their programmable blocks myself. I suppose this is my 'waypoint manager' as you describe.

    It's useful to have a reference to all the ships I have moving around anyway, so it wasn't too bad. No need to shift your priorities :)
     
Thread Status:
This last post in this thread was made more than 31 days old.