Modding Discussion 1.0 Update, It's going to arrive sooner or later. So let's prepare for it!

Discussion in 'Starbound Modding' started by C0bra5, Jun 19, 2016.

  1. The | Suit

    The | Suit Agent S. Forum Moderator

    Going to sticky this thread for a week or two - until some new tutorials and guides roll out.
    --- Post updated ---
    The Lua Docs have been added to the starbound directory, in the Docs folder.
    Feel free to thank @metadept - who worked tirelessly to get it ready in time - https://twitter.com/metadept
    --- Post updated ---
    Lua Docs Update - https://t.co/dsMt5QBxHn
     
    bk3k, Darkblader24, C0bra5 and 3 others like this.
  2. Darkblader24

    Darkblader24 Phantasmal Quasar

    In lua args.actions seems to be removed. Is there any replacement for this?
     
  3. C0bra5

    C0bra5 Oxygen Tank

    there is no input function so the action thing as been removed. i got a work around for my mod so here have a look
    Code:
    function init()
        -- RAINBOOM VARIABLES
        self.airDashing = false
        self.dashing = false
        self.dashTimer = 0
        self.dashDirection = 0
        self.dashLastInput = 0
        self.dashTapLast = 0
        self.dashTapTimer = 0
        -- FLIGHT VARIABLES
        self.lastJump = false
        self.lastBoost = {boostRightUp = false, boostRightDown = false, boostLeftUp = false, boostLeftDown = false, boostRight = false, boostLeft = false, boostUp = false, boostDown = false }
        -- CUSTOM VARIABLES
        self.isFlying = false
        self.isRainboom = false
        -- DASH ACTION REPLACER
        self.rainboomAction = nil
    end
    
    function input(args)
        local currentBoost = {boostRightUp = false, boostRightDown = false, boostLeftUp = false, boostLeftDown = false, boostRight = false, boostLeft = false, boostUp = false, boostDown = false }
    
        if args.moves["up"] == true or args.moves["down"] == true or args.moves["left"] == true or args.moves["right"] == true or args.moves["jump"] == true then
        -- VISUAL DEBUGING HELP
        --debughelp()
       
        -- FLIGHT VARIABLES
        local currentJump = args.moves["jump"]
    
        -- RAINBOOM TIMER
        if self.dashTimer > 0 then
        --    return nil
        end
       
        -- RAINBOOM ACTION REPLACER TO NIL
        self.rainboomAction = nil
    
        -- RAINBOOM VARIABLES
        local maximumDoubleTapTime = config.getParameter("maximumDoubleTapTime")
    
        -- RAINBOOM DOUBLE TAP TIMER
        if self.dashTapTimer > 0 then
            self.dashTapTimer = self.dashTapTimer - args.dt
        end
       
        --RAINBOOM INPUT SCRIPT
        if args.moves["right"] then
            if self.dashLastInput ~= 1 then
                if self.dashTapLast == 1 and self.dashTapTimer > 0 then
                    self.dashTapLast = 0
                    self.dashTapTimer = 0
                    self.rainboomAction = "dashRight"
                else
                    self.dashTapLast = 1
                    self.dashTapTimer = maximumDoubleTapTime
                end
            end
            if self.rainboomAction == nil then
                self.dashLastInput = 1
            end
        elseif args.moves["left"] then
            if self.dashLastInput ~= -1 then
                if self.dashTapLast == -1 and self.dashTapTimer > 0 then
                    self.dashTapLast = 0
                    self.dashTapTimer = 0
                    self.rainboomAction = "dashLeft"
                else
                    self.dashTapLast = -1
                    self.dashTapTimer = maximumDoubleTapTime
                end
            end
            if self.rainboomAction == nil then
                self.dashLastInput = -1
            end
        else
            self.dashLastInput = 0
        end
       
        -- FLIGHT INPUT SCRIPT
        if not mcontroller.onGround() then
            if not mcontroller.canJump() and currentJump and not self.lastJump then
                if args.moves["right"] and args.moves["up"] then
                    currentBoost["boostRightUp"] = true;
                elseif args.moves["right"] and args.moves["down"] then
                    currentBoost["boostRightDown"] = true;
                elseif args.moves["left"] and args.moves["up"] then
                    currentBoost["boostLeftUp"] = true;
                elseif args.moves["left"] and args.moves["down"] then
                    currentBoost["boostLeftDown"] = true;
                elseif args.moves["right"] then
                    currentBoost["boostRight"] = true;
                elseif args.moves["down"] then
                    currentBoost["boostDown"] = true;
                elseif args.moves["left"] then
                    currentBoost["boostLeft"] = true;
                elseif args.moves["up"] then
                    currentBoost["boostUp"] = true;
                end
            end
        end
       
        if self.isFlying and not mcontroller.onGround() then
            if args.moves["right"] and args.moves["up"] then
                currentBoost["boostRightUp"] = true
            elseif args.moves["right"] and args.moves["down"] then
                currentBoost["boostRightDown"] = true
            elseif args.moves["left"] and args.moves["up"] then
                currentBoost["boostLeftUp"] = true
            elseif args.moves["left"] and args.moves["down"] then
                currentBoost["boostLeftDown"] = true
            elseif args.moves["right"] then
                currentBoost["boostRight"] = true
            elseif args.moves["down"] then
                currentBoost["boostDown"] = true
            elseif args.moves["left"] then
                currentBoost["boostLeft"] = true
            elseif args.moves["up"] then
                currentBoost["boostUp"] = true
            elseif self.lastJump and currentJump then
                currentBoost = self.lastBoost;
            end
        end
        self.lastJump = currentJump
       
       
        debughelp()
       
        end
        self.lastBoost = currentBoost
        return currentBoost
    end
    
    function update(args)
        args.actions = input(args)
       
       
        --FLIGHT VARIABLES
        local boostControlForce = config.getParameter("boostControlForce")
        local boostSpeed = config.getParameter("boostSpeed")
        local energyUsagePerSecond = config.getParameter("energyUsagePerSecond")
        local diag = 1 / math.sqrt(2)
        local boostDirection = false
       
        --RAINBOOM VARIABLES
        local dashControlForce = config.getParameter("dashControlForce")
        local dashSpeed = config.getParameter("dashSpeed")
        local dashDuration = config.getParameter("dashDuration")
        local groundOnly = config.getParameter("groundOnly")
        local groundValid = not groundOnly or mcontroller.onGround()
       
        -- RAINBOOM SCRIPT
        if self.rainboomAction == "dashRight" and groundValid and self.dashTimer <= 0 and status.overConsumeResource("energy",config.getParameter("energyUsage")) then
            self.dashTimer = dashDuration
            self.dashDirection = 1
            self.airDashing = not mcontroller.onGround()
        elseif self.rainboomAction == "dashLeft" and groundValid and self.dashTimer <= 0 and status.overConsumeResource("energy",config.getParameter("energyUsage")) then
            self.dashTimer = dashDuration
            self.dashDirection = -1
            self.airDashing = not mcontroller.onGround()
        end
    
        if self.dashTimer > 0 then
            mcontroller.controlApproachXVelocity(dashSpeed * self.dashDirection, dashControlForce, true)
            self.dashing = true
    
            if self.airDashing then
                mcontroller.controlParameters({gravityEnabled = false})
                mcontroller.controlApproachYVelocity(0, dashControlForce, true)
            end
    
            if self.dashDirection == -1 then
                mcontroller.controlFace(-1)
                animator.setFlipped(true)
            else
                mcontroller.controlFace(1)
                animator.setFlipped(false)
            end
            --RAINBOOM ANIMATION ON
            animator.setAnimationState("dashing", "on")
            animator.setParticleEmitterActive("dashParticles", true)
            animator.setParticleEmitterActive("dashParticles2", true)
            self.dashTimer = self.dashTimer - args.dt
            self.isRainboom = true
        else
            --RAINBOOM ANIMATION OFF
            animator.setAnimationState("dashing", "off")
            animator.setParticleEmitterActive("dashParticles", false)
            animator.setParticleEmitterActive("dashParticles2", false)
           
            --
            if self.dashing and config.getParameter("stopAfterDash") then
                local movementParams = mcontroller.baseParameters()
                mcontroller.controlApproachXVelocity(self.dashDirection * movementParams.runSpeed, dashControlForce)
            end
            self.dashing = false
            self.isRainboom = false
        end
        -- FLIGHT SCRIPT
    
        if args.actions["boostRightUp"] then
            boostDirection = {boostSpeed * diag, boostSpeed * diag}
        elseif args.actions["boostRightDown"] then
            boostDirection = {boostSpeed * diag, -boostSpeed * diag}
        elseif args.actions["boostLeftUp"] then
            boostDirection = {-boostSpeed * diag, boostSpeed * diag}
        elseif args.actions["boostLeftDown"] then
            boostDirection = {-boostSpeed * diag, -boostSpeed * diag}
        elseif args.actions["boostRight"] then
            boostDirection = {boostSpeed, 0}
        elseif args.actions["boostDown"] then
            boostDirection = {0, -boostSpeed}
        elseif args.actions["boostLeft"] then
            boostDirection = {-boostSpeed, 0}
        elseif args.actions["boostUp"] then
            boostDirection = {0, boostSpeed}
        end
       
        if boostDirection and status.overConsumeResource("energy",energyUsagePerSecond * args.dt) then
            if self.isRainboom then
                mcontroller.controlApproachVelocity({boostDirection[1] * 100, boostDirection[2]}, boostControlForce, true, true)
            else
                mcontroller.controlApproachVelocity(boostDirection, boostControlForce, true, true)
            end
            self.isFlying = true
        else
            self.isFlying = false
        end
       
    end
    
    function debughelp(x)
        if self.isFlying  then
            world.debugText("flying",{mcontroller.position()[1]-1,mcontroller.position()[2]-3.5}, "green")
        else
            world.debugText("not flying",{mcontroller.position()[1]-1.5,mcontroller.position()[2]-3.5}, "red")
        end
       
        if self.isRainboom  then
            world.debugText("rainboom",{mcontroller.position()[1]-1.8,mcontroller.position()[2]+1.5}, "green")
        else
            world.debugText("no rainboom",{mcontroller.position()[1]-2,mcontroller.position()[2]+1.5}, "red")
        end
       
        if mcontroller.onGround()  then
            world.debugText("on ground",{mcontroller.position()[1]-1.8,mcontroller.position()[2]+2.5}, "green")
        else
            world.debugText("not on ground",{mcontroller.position()[1]-2,mcontroller.position()[2]+2.5}, "red")
        end
    
    end
     
  4. Darkblader24

    Darkblader24 Phantasmal Quasar

    Thanks! I do now use one string for all the actions.

    But I noticed another thing: They removed Special 2 and 3!
    This takes away a lot of button combinations! Or am I just stupid and I can't find it?
     
  5. C0bra5

    C0bra5 Oxygen Tank

    nope they "removed it" it unbinded by default and has to be patched in
     
    Darkblader24 likes this.
  6. Darkblader24

    Darkblader24 Phantasmal Quasar

    Omg, thanks! I already thought the worst.
     
  7. NeoslayerX

    NeoslayerX Big Damn Hero

    I hate being new.. Eventually in some point in time, I'll be chuckling at my lack of knowledge for this game or its Modding..

    But.. I thought this game was 1.3..
     
  8. bk3k

    bk3k Oxygen Tank

    The current stable build is 1.0.4
     
  9. C0bra5

    C0bra5 Oxygen Tank

    Terraria is in it's 1.3 versions if I'm not wrong
     

Share This Page