Lua API documentation

Discussion in 'Starbound Modding' started by OmnipotentEntity, Apr 3, 2014.

Thread Status:
Not open for further replies.
  1. SouperDaveCDN

    SouperDaveCDN Orbital Explorer

    Thanks for the quick response Kawa, that will be helpful. Now just have to find some basic(ish) script examples to test out!
     
  2. Kawa

    Kawa Tiy's Beard

    This isn't even my field, so I'm happy to be of assistance.
     
  3. I Said No

    I Said No Cosmic Narwhal

    Not sure where else to put this query and it doesn't really warrant its own topic, so here it is.
    Is there a function to get the currently active weather condition? I can't tell if i've just missed it or if it isn't implemented.
     
    sayter and RatixFarrence like this.
  4. The | Suit

    The | Suit Agent S. Forum Moderator

    Not yet
     
    RatixFarrence likes this.
  5. shardshunt

    shardshunt Cosmic Narwhal

    link broken error 522
     
    Frank_Irony likes this.
  6. Its the correct link... the website is just down right now/having issues
     
    OmnipotentEntity and shardshunt like this.
  7. heinermann

    heinermann Scruffy Nerf-Herder


    Can you change the doxygen settings to include undocumented commands and also fix some of the mismatched parameters? (i.e. Star::LuaBindings::WorldEnvironmentCallbacks::placeMaterial just has arg1, arg2, arg3....)
     
    Last edited by a moderator: Apr 16, 2015
  8. KridOCaign

    KridOCaign Void-Bound Voyager

    I don't see any functions for handling persistent data storage. Could we get some sanitized read/write functions so mods can save some data?
    Ideally we would be able to store data on a per-world basis, but read it from anywhere.

    A specific application would be a 'captain's log' in which players could store notes on planets, or a 'scanner' which automatically lists things the player encountered on that planet (ie: villages, dungeons, ore types).
     
  9. You can't read about what doesn't exist...
     
  10. nevir

    nevir Big Damn Hero

    The link is missing /stable/
     
  11. The | Suit

    The | Suit Agent S. Forum Moderator

    Well that is because you are replying to a post a few months old.
    The link was accurate at the time it was posted.
    Once the new Starboudnm Unstable link hit, it was broken up into stable \ unstable groups in docs.
     
  12. Narks

    Narks Scruffy Nerf-Herder

    When will get get Lua API documentation?
     
  13. floram

    floram Master Chief

    Yeah I'd like to see Lua API documentation come back.
     
  14. NillByeScience

    NillByeScience Void-Bound Voyager

    hello yes I would like documentation again
     
  15. C0bra5

    C0bra5 Oxygen Tank

    I've actually been working on an unofficial version of it, but i'm so busy with real life stuff like my job and trying to get my 4 hours of sleep a day that i haven't updated it in forever. there is an almost full description and usage example documentation of the status table and a really incomplete version of the mcontroller table available and i've also listed all the functions from the world table but i haven't written anything yet.

    the old documentation website(doc.playstarbound.com/whatever/) has acually been removed because there was almost no documentation about the lua api itself. it mostly contained some c++ documentation of the source code that we cannot access.

    anyway here is some sweet things you can do if you need to check the content or availability of a certain function in a certain table:

    list the content of a table
    Code:
    --it will run through the table and print the content in your log
    for key,value in pairs([table here]) do
        world.logInfo(k.." : "..tostring(v));
    end
    _ENV
    this is the evironement, so you can find all the stuff you can acces from it.

    here is a sweet way to print the content of _ENV, just put that in a tech script, unlock the teck and activate it, and it should print every table and their content in your log:

    Code:
    function init()
        printTable(0,_ENV);
    end
    
    --prints table
    function printTable(indent, value)
        local tabs = "";
        for i=1,indent,1 do
            tabs = tabs.."    ";
        end
        table.sort(value)
        for k,v in pairs(value) do
            world.logInfo(tabs..getValueOutput(k,v));
            if type(v) == "table" then
                if tostring(k) == "utf8" then
                    world.logInfo("    "..tabs.."SKIPPING UTF8 SINCE IT SEEMS TO HAVE NO END AND JUST BE FILLED WITH TABLES OF TABLES")
                else
                    if tableLen(v) == 0 then
                        world.logInfo("    "..tabs.."EMPTY TABLE")
                    else
                        printTable(indent+1,v);
                      
                    end
                end
                world.logInfo(" ");
            end
        end
      
    end
    
    function tableLen(T)
      local count = 0
      for _ in pairs(T) do count = count + 1 end
      return count
    end
    
    --Required for printTable
    function getValueOutput(key ,value)
        if type(value) == "table" then
            return "table : "..key;
        elseif type(value) == "function" then
            return "function : "..key.."()"
        elseif type(value) == "string" then
            return "string : "..key.." - \""..tostring(value).."\"";
        else
            return type(value).." : "..key.." - "..tostring(value);
        end
    end
    

    if your are too lazy to do that i went a head and ran it for anyone who is curious of what it can print

    Code:
    table : sb
        function : printJson()
        function : interpolateSinEase()
        function : logInfo()
        function : makeUuid()
        function : print()
        function : nrand()
    
    function : rawset()
    function : jobject()
    function : getValueOutput()
    function : select()
    function : next()
    function : assert()
    function : getmetatable()
    table : self
        EMPTY TABLE
    
    function : print()
    function : tonumber()
    table : storage
        EMPTY TABLE
    
    table : os
        function : clock()
        function : time()
        function : difftime()
    
    function : xpcall()
    table : string
        function : char()
        function : rep()
        function : reverse()
        function : find()
        function : upper()
        function : match()
        function : gsub()
        function : unpack()
        function : packsize()
        function : len()
        function : pack()
        function : lower()
        function : byte()
        function : sub()
        function : format()
        function : dump()
        function : gmatch()
    
    table : world
        function : npcQuery()
        function : containerAddItems()
        function : entityQuery()
        function : containerAvailable()
        function : spawnItem()
        function : containerSwapItems()
        function : placeMod()
        function : debugText()
        function : spawnStagehand()
        function : entityHandItem()
        function : containerSize()
        function : loungeableQuery()
        function : debugLine()
        function : stagehandType()
        function : time()
        function : isMonster()
        function : logInfo()
        function : underground()
        function : objectSpaces()
        function : lineTileCollision()
        function : placeObject()
        function : containerOpen()
        function : spawnNpc()
        function : liquidAt()
        function : spawnLiquid()
        function : isTileProtected()
        function : rectCollision()
        function : breathable()
        function : xwrap()
        function : setLogMap()
        function : spawnMonster()
        function : resolvePolyCollision()
        function : npcLineQuery()
        function : windLevel()
        function : day()
        function : containerItemsCanFit()
        function : playerQuery()
        function : containerPutItemsAt()
        function : entityExists()
        function : lightLevel()
        function : containerItems()
        function : monsterType()
        function : platformerPathStart()
        function : findPlatformerPath()
        function : isNpc()
        function : itemType()
        function : entityHandItemDescriptor()
        function : setProperty()
        function : spawnProjectile()
        function : threatLevel()
        function : debugPoint()
        function : entityName()
        function : objectQuery()
        function : containerConsume()
        function : spawnTreasure()
        function : timeOfDay()
        function : tileIsOccupied()
        function : collisionBlocksAlongLine()
        function : rectTileCollision()
        function : pointTileCollision()
        function : polyContains()
        function : distance()
        function : polyCollision()
        function : entityMoney()
        function : material()
        function : destroyLiquid()
        function : monsterQuery()
        function : containerItemAt()
        function : containerClose()
        function : containerStackItems()
        function : sendEntityMessage()
        function : entityVelocity()
        function : objectLineQuery()
        function : itemDropQuery()
        function : entityHealth()
        function : entityLineQuery()
        function : farmableStage()
        function : loungeableOccupied()
        function : objectConfigParameter()
        function : damageTiles()
        function : containerConsumeAt()
        function : containerTakeAt()
        function : entityPosition()
        function : containerTakeNumItemsAt()
        function : gravity()
        function : magnitude()
        function : entitySpecies()
        function : entityUniqueId()
        function : containerSwapItemsNoCombine()
        function : entityType()
        function : placeMaterial()
        function : callScriptedEntity()
        function : getProperty()
        function : containerItemsFitWhere()
        function : containerItemApply()
        function : containerTakeAll()
        function : mod()
        function : logWarn()
        function : logError()
    
    table : root
        function : recipesForItem()
        function : projectileGravityMultiplier()
        function : projectileConfig()
        function : nonEmptyRegion()
        function : imageSize()
        function : liquidStatusEffects()
        function : evalFunction2()
        function : generateName()
        function : getMatchingTenants()
        function : npcConfig()
        function : behaviorModule()
        function : assetJson()
        function : createItem()
        function : imageSpaces()
        function : tenantConfig()
        function : evalFunction()
        function : itemType()
        function : itemConfig()
    
    table : status
        function : modifyResource()
        function : inflictedDamageSince()
        function : damageTakenSince()
        function : resource()
        function : clearEphemeralEffects()
        function : resourceLocked()
        function : consumeResource()
        function : resourceNames()
        function : addEphemeralEffects()
        function : clearAllPersistentEffects()
        function : resourcePercentage()
        function : clearPersistentEffects()
        function : removeEphemeralEffect()
        function : resourcePositive()
        function : setResourcePercentage()
        function : isResource()
        function : resetAllResources()
        function : setStatusProperty()
        function : setResourceLocked()
        function : resetResource()
        function : addPersistentEffect()
        function : statPositive()
        function : addPersistentEffects()
        function : modifyResourcePercentage()
        function : stat()
        function : addEphemeralEffect()
        function : statusProperty()
        function : setPersistentEffects()
        function : overConsumeResource()
        function : resourceMax()
        function : setResource()
    
    function : jarray()
    function : ipairs()
    function : error()
    table : tech
        function : burstParticleEmitter()
        function : setLightActive()
        function : setPartTag()
        function : setSoundPool()
        function : setParticleEmitterOffsetRegion()
        function : setSoundPosition()
        function : setFlipped()
        function : setLightPointAngle()
        function : partPoly()
        function : setGlobalTag()
        function : animationState()
        function : currentScale()
        function : animationStateProperty()
        function : setParentOffset()
        function : setParticleEmitterActive()
        function : currentRotationAngle()
        function : playSound()
        function : setParentState()
        function : partPoint()
        function : setEffectActive()
        function : scaleGroup()
        function : setAnimationState()
        function : transformedPosition()
        function : setToolUsageSuppressed()
        function : parameter()
        function : rotateGroup()
        function : parentLounging()
        function : setParentDirectives()
        function : consumeTechEnergy()
        function : setVisible()
        function : aimPosition()
        function : hasSound()
        function : setLightPosition()
        function : setParticleEmitterEmissionRate()
        function : setAnimationRate()
    
    function : pairs()
    function : require()
    function : setmetatable()
    table : table
        function : move()
        function : concat()
        function : sort()
        function : remove()
        function : unpack()
        function : insert()
        function : pack()
    
    function : pcall()
    table : coroutine
        function : create()
        function : status()
        function : running()
        function : yield()
        function : resume()
        function : isyieldable()
        function : wrap()
    
    function : jresize()
    function : type()
    table : entity
        function : isValidTarget()
        function : id()
        function : entityInSight()
        function : damageTeam()
        function : distanceToEntity()
        function : closestValidTarget()
    
    table : mcontroller
        function : onGround()
        function : rotation()
        function : baseParameters()
        function : controlCrouch()
        function : controlAcceleration()
        function : positionDelta()
        function : measuredVelocity()
        function : isCollisionStuck()
        function : walking()
        function : controlDown()
        function : setYVelocity()
        function : controlFace()
        function : falling()
        function : running()
        function : translate()
        function : isNullColliding()
        function : setXVelocity()
        function : addMomentum()
        function : controlMove()
        function : position()
        function : setAutoClearControls()
        function : collisionBody()
        function : xVelocity()
        function : yVelocity()
        function : controlFly()
        function : controlApproachXVelocity()
        function : controlApproachYVelocity()
        function : liquidId()
        function : controlModifiers()
        function : setPosition()
        function : controlJump()
        function : controlHoldJump()
        function : controlApproachVelocity()
        function : controlForce()
        function : controlRotation()
        function : liquidMovement()
        function : setVelocity()
        function : jumping()
        function : liquidPercentage()
        function : flying()
        function : facingDirection()
        function : crouching()
        function : boundBox()
        function : movingDirection()
        function : clearControls()
        function : setRotation()
        function : collisionPoly()
        function : velocity()
        function : controlParameters()
        function : autoClearControls()
        function : xPosition()
        function : yPosition()
        function : canJump()
        function : isColliding()
    
    function : jremove()
    function : debughelp()
    function : update()
    function : rawget()
    table : utf8
        SKIPPING UTF8 SINCE IT SEEMS TO HAVE NO END AND JUST BE FILLED WITH TABLES OF TABLES
    
    table : math
        number : maxinteger - 9223372036854775807
        function : floor()
        function : max()
        function : ceil()
        function : cos()
        function : random()
        number : mininteger - -9223372036854775808
        function : atan()
        number : huge - inf
        number : pi - 3.1415926535898
        function : exp()
        function : acos()
        function : type()
        function : deg()
        function : sqrt()
        function : tointeger()
        function : sin()
        function : modf()
        function : fmod()
        function : randomseed()
        function : asin()
        function : min()
        function : rad()
        function : abs()
        function : log()
        function : ult()
        function : tan()
    
    function : printTable()
    function : init()
    string : _VERSION - "Lua 5.3"
    function : tostring()
    function : rawlen()
    function : input()
    function : rawequal()
    function : tableLen()
    function : jsize()
    table : script
        function : setUpdateDelta()
        function : updateDt()
    


    If you want to see what I've written so far as for unnoficial documentation, you can find it here: www.sblaud.net
     
  16. Narks

    Narks Scruffy Nerf-Herder

    No parameters... No way to get them because the debug library is disabled. If a function is not used in vanilla Starbound (as most are), it's basically impossible to use unless you want to spend days guessing the parameters... so listing everything in the Lua environment is useless.
     
    Last edited: Nov 20, 2015
  17. C0bra5

    C0bra5 Oxygen Tank

    yaaa... that's why it takes me so long to document the api, though i copied my files extracted from the assets.pak file, extracted all the lua files and put their content in one single file, allowing me to search quickly for a function name and 99% of the time get the parameters. i also had the modding irc which can help sometimes
     
  18. Narks

    Narks Scruffy Nerf-Herder

    lua api when
     
  19. C0bra5

    C0bra5 Oxygen Tank

    Either once i start having some free time or once the devs make it.
     
  20. The | Suit

    The | Suit Agent S. Forum Moderator

    Its likely the new Docs should be up soon - considering most of the developments seem to be focusing on more and more newer objects. Its likely they want to see how far they can push the Lua before they add the docs for it.
     
Thread Status:
Not open for further replies.

Share This Page