Lua API Exposed... Sort of.

Discussion in 'Starbound Modding' started by severedskullz, Dec 8, 2013.

  1. kieve

    kieve Intergalactic Tourist

    I don't think IO is strictly necessary. Giving us a sandboxed way of "saving files" for state and an API for communicating with the server would work fine.
     
  2. looter

    looter Void-Bound Voyager

    They could just do what garry did for garrysmod and have a custom IO wrapper that only allows people to read and write json and have it restricted to a directory. Would be nice, and could even have table -> json and json -> table functions too.
     
    Partack and rektide like this.
  3. APXEOLOG

    APXEOLOG Void-Bound Voyager

    I already made table -> json function, maybe i will upload here my lua lib.
     
    looter likes this.
  4. looter

    looter Void-Bound Voyager

    I would be interested in adding it to the Starbound Template Library.
     
  5. Scelestic

    Scelestic Big Damn Hero

    Anyone found a way to expose the name of the planet you are on?
     
  6. rektide

    rektide Space Hobo

    I really really like this idea!

    As for getting data into the game, I'm not sure how great this would be. I could see having an external program writing one file, over and over, and having Starbound keep reading it. Having a more interrupt driven means of pulling data in would be a great complement.

    Really hope we see some kind of way to linkup starbound with the external world make it's way into the available API. Great suggestion looter.
     
  7. bizzy401

    bizzy401 Subatomic Cosmonaut

    Nice work...

    (I loled at the emotes :) )
     
  8. madtulip

    madtulip Phantasmal Quasar

    is there any write variant of world.material yet that i dont find? you seem to be able to spawn most other things, i wonder why blocks are not in, or do i miss something ?
     
  9. Supergeek

    Supergeek Scruffy Nerf-Herder

    The Angry Koala patch has implemented placeMaterial. See the /assets/scripts/API directory for docs.
     
  10. madtulip

    madtulip Phantasmal Quasar

    ah yes thanks. ive multi posted that request :) wrote more in the lua feature request topic by "looter" :) thanks man.
     
  11. Asvarduil

    Asvarduil Astral Cartographer

    I'm looking into world.material, for the mod I am currently working on.
     
  12. The | Suit

    The | Suit Agent S. Forum Moderator

    Does anyone know how to create a "wait" timer?
    I want an action to be performed after a certain amount of seconds.
     
  13. Heliostorm

    Heliostorm Phantasmal Quasar

    There's an args.dt that gives how much time has passed between function calls, check the energy dash tech for how it's used (it's used there to check how much time passes between keypresses).
     
  14. madtulip

    madtulip Phantasmal Quasar

    Im using this in a main to execute only every 3s:
    Code:
    // in Init:
    self.time_to = os.time();
    local delay_in_s = 3
    // in main (looped)
    if(os.time() >= self.time_to) then
      do_stuff()
      self.time_to = os.time() + delay_in_s;
    end
    This is not a wait, it just cares for only execute this every 3s+x(depending on while loop time).
    I triied doing it whith a while(time) instead of polling the if inside a thread (coroutine). The strange thing is that also this while is threaded the main loop of starbound also waits while the thread waits (player can move, but monsters "hang" for the timer ammount) ... thats kinda the thing you want about a thread, that it is in a different context with its own current execution pointer, no? anyway.
     
    Last edited: Dec 27, 2013
    Partack likes this.
  15. The | Suit

    The | Suit Agent S. Forum Moderator

    @madtulip
    I was reading about this script,
    People advised against it saying it completely eats up cycles while waiting.
    I don't know if its true or not.
     
  16. madtulip

    madtulip Phantasmal Quasar

    well that depends on what you want to do. your main will be called each cycle. if this is in main main will exit quite fast again. no big difference to not having it in at all. so it doesnt eat a lot of resources. it would be even better if you could have that timer in a thread holding a while. but that doesnt work at because the "sleeping" thread hold parts of starbounds main which is odd to me.
     
  17. Asvarduil

    Asvarduil Astral Cartographer

    In the Unity game engine, when we want to do a timing effect in Update() (the same thing as this engine's Main function), we do this approach:

    Code:
    public void Update()
    {
        if(Time.time < lastEvent)
            return;
    
        // ...Do what you were going to do...
    }
    This seems like the correct approach to take in the Starbound engine too. :)

    Code:
    function main()
      if ! canDoThingAgain then
        return;
    
      -- Do the things.
    end
     
  18. The | Suit

    The | Suit Agent S. Forum Moderator

    @madtulip @Asvarduil

    Thanks for all the help.
    I figured out a different method in which the game normally uses.
    With main and setting up via variable.
    Its slightly more complex to balance because its dependent on the DeltaScript

    But I was able to get it finally to time the animation with the code. Which was what I was trying to accomplish
    Will posts results after getting everything to work accordingly to make sure there are no other side effects due to the code.
     
    Partack likes this.
  19. Partack

    Partack Astral Cartographer

    Well, do share..
    More knowledge to the masses!

    What was your method?
     
  20. The | Suit

    The | Suit Agent S. Forum Moderator

    I will - but I need to test it out a bit more.
    Since there is no way to properly calculate the animation timing via my method.
    So I am guessing there would be a more "offical" approach - which I seem to be missing right now.
    I will release what I find in a few days - no worries.
     
    Sherl0ck and Partack like this.

Share This Page