This will be a thread for community requests regarding the Lua implementation in Starbound. Feel free to discuss requests in this thread or suggest ones of your own to be added to the OP. A lot of the suggestions I have made are to try to make Starbound more friendly for general gameplay oriented coding rather than object/entity specific operations. Global & Registry Table It would be nice to have a normal global table instance so that scripts can access, modify and reference global lua variables easily. Right now, the only way this is possible is to tack on variables to the few global lua libraries we have (string, math, etc.) quote from jordo about this request Code: [12:28] <looter> jordo, any chance we could get a global mutable _G that each script can access during runtime? i would love to write some helper functions (similar to vec2, util for monsters) that each script could use, could also serve as a place to store things between contexts [12:28] <+jordo> looter - probably not, but you can certainly include helpers like vec2 or util [12:29] <+jordo> and use callScriptedEntity to talk between them [12:29] <+jordo> and im adding a thing [12:29] <+jordo> so you can [12:29] <+jordo> local npc = entityProxy.create(npcEntityId) [12:29] <+jordo> npc.say("blah") Scripts Directory It would be awesome to have a set directory for scripts to reside in to keep it organized, something like assets/scripts/<sub folder>/main.lua , where main.lua is executed during initialization and subscripts can be organized throughout the sub directory. quote from jordo about this request Code: [12:47] <+jordo> looter - scripts directory you can set up like that now - objects/monsters/npcs just include a list of scripts, so you could put one func in each if you wanted [12:49] <looter> interesting, ok, is it possible to have scripts included without them being referenced by an objects definition file? right now i have been getting my non-object/entity specific code to run by overwriting npcs/main.lua [12:50] <+jordo> in the .npctype you can add to the list of scripts, but otherwise no require is off Hook Library Coming from a GLua (garrysmod lua) background, I can't express how useful a native hook library can be to game modding. Mods could simply define hooks that are called natively by the game when certain events happen, and pass the hook functions arguments within the events contexts. For example, Starbound would hook.Call("PlayerSpawned", PlayerID, ...) when a player spawns in the game, and mods using that hook can do what they need to do cleanly. This also allows for mods to define custom hooks that other mods can use, which is very useful. quote from jordo about this request Code: [12:48] <+jordo> hooks - well essentially there're a set of global function you can define [12:49] <+jordo> we just need to document them / solidify the api [12:49] <+jordo> as they vary depending on what's running the script Network Library For complex mods, it will be essential to have server->client, client->server logic and architecture to function properly and be authoritative, a great example of a networking library that would be useful to imitate is here. quote from jordo about this request Code: [12:47] <+jordo> network im not sure - luasocket requires dllopen i think [12:48] <+jordo> we're compiling lua without dllopen Bindings dofile ([filename]) loadfile ([filename]) loadstring (string [, chunkname]) load (func [, chunkname]) getfenv (object) setfenv (f, table) setmetatable (table, metatable) getmetatable (object) setParameter( key, value ) coroutine.* library seems to exist within _ENV modules (package.*) library debug.* library It seems _ENV might be the global table for starbound, which contains some of the binding requests, feel free to try using them and report back. http://privatepaste.com/91ddf79be8
I created a post that was similar, but much less specific to lua. It's from an SE perspective of trying to develop a mod. I'll leave it here for reference. http://community.playstarbound.com/index.php?threads/modding-framework-api-issues.45953/
I have a request: Don't put the wire logic in a separate sandbox than techs. More generally, we don't need to play in many sandboxes. Supporting my theory that this is happening: If you attach a property to the global math library (Example: math["TEST"] = "I'm here") from an object (such as a wire switch), all objects will be able to read that property. For a tech? It would be null.
Agreed, lots of sandboxing going on within the code right now, hopefully we can just get a lua environment with a global and reference table.
That was close to solving this problem. The method is able to use the same variable in different objects as described (though an uggly way of doing it as far as i can tell - never did lua, did a lot of C,C++). There are different instances of math for the shipworld and the planetworld as well (as between tech and object) which means you can not transfer data from ship to planet doing this . So i as well request a true global or at least access to the layer which instances shipworld and planetworld.
btw. i also nicely REQUEST a minimal api just giving a full list auf function name and parameter. It doesnt even need any description for now. i understand if there is no time for that but just copiing the headers takes 10minutes guys, cmon.
APXEOLOG found what seems to be the global table _ENV, so play around with it. If its not just copied and passed to each script instance, it could serve very useful. Here is a dump he did on it http://privatepaste.com/91ddf79be8 For now jordo is working on fleshing out https://gist.github.com/jordoh/7864154 when he has time
Thank you looter for taking the head for us programming interested and push it. As it seems nothing is in stone and this effort could result in better tools for us
Thanks! I'm awful at art, so the programming side of things is all I'm really interested in. I can't wait until Starbound is in a state to where we can begin coding our own gameplay features rather than adding more of the same, and have no doubt that we will get to that point eventually, these are the friendliest and most helpful developers in the gaming industry right now. I really think alot of other companies could learn quite a bit from Chucklefish.
request: --- Sets the type of the material at the given tile position -- -- @param position The { x, y } position to place material at -- @param material The .material name to place -- @param layer The layer to use: "foreground" or "background" -- -- @returns 42 as every good function world.set_material = function(position, material, layer) end,
request: player entity invulnerable in shipworld as a parameter in player.config instead of hard coded
* remove or grant player pixels, negative int to remove, positive int to grant: player.addPixels(-5); returns 0 if failure (not enough Pixels to charge negative), 1 on success * entity.onHear() whenever something is "said" in close vicinity to NPCs, they can process the heard speech. Code: entity.onHear(entityid, speech) { if find.speech("shut up") then emote("why the hate, ".. entity.id .. "?") end }
Requesting: Access to read and writeable context which is persistant between instances of shipworld and planetworld.
technically you can do that since i do not believe they disregard the previous interpreters state, you'd just need the previous state (at certain intervals shipworld\planetworld lua states are reinitalized, not just when you beam, couldn't tell you why)
The first part is probably hillarious, but i didnt get it . you mean to try get a pointer to the one worlds memory as it exists and hope that the data there is still intact once its deconstructed? could you explain ? The 2nd part is probably due to the einstein approoved praxis of :"If something doesnt work, try it againt and exspect a different result."