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.
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.
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.
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 ?
ah yes thanks. ive multi posted that request wrote more in the lua feature request topic by "looter" thanks man.
Does anyone know how to create a "wait" timer? I want an action to be performed after a certain amount of seconds.
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).
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.
@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.
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.
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
@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.
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.