Modding Discussion Need Help: Block Placement Increasing

Discussion in 'Starbound Modding' started by KingLazarus, Feb 3, 2016.

  1. KingLazarus

    KingLazarus Void-Bound Voyager

    Hey guys. I am new to the modding community. Anyway I am trying to figure out or find a mod that will increase the placement from 2x2 to something bigger. Like 6x6 or 16x16 or whatever number I can come up with. I did find one mod here on the site that's called, "Large Scalre Building (4x4)" However it doesn't work in the most recent update. It keeps telling me that there is a crash to the game because of "money" and it sends me to a file folder that doesn't exist.

    Here is the link to the mod: http://community.playstarbound.com/resources/large-scale-building-4x4.2539/

    So please don't send me to that mod. What I need is a step by step exact instructions on how to make this mod myself (not the 4x4 one) for the version of Starbound "Glad Giraffe".

    Any help please.Thanks. And I am using the steam version.
     
  2. Errors4l

    Errors4l Spaceman Spiff

    Looking at the content of the mod, it seems like it only changes two parameters in the defaultparameters configuration file.
    The mod replaces this file, instead of using the (now pretty standard) patch system. This means when the vanilla defaultparameters file change, the mod practically reverts these changes causing the game to crash.
    The /items/defaultparameters.config should be removed and replaced with a new /items/defaultparameters.config.patch file, containing something like the following (which has not been tested):
    Code:
    [{
        "op": "replace",
        "path": "/blockRadius",
        "value": 4
    },
    {
        "op": "replace",
        "path": "/defaultMaxStack",
        "value": 6400
    }]
    If that piece of code does not work, you'll have to look up the patch syntax yourself. There's documentation on these forums for it.
     
    Relten likes this.
  3. KingLazarus

    KingLazarus Void-Bound Voyager

    Seems legit, I am just not versed in coding and command scripting. That's why I was asking if someone can walk me through it step by step.... Thank you
     
  4. Mackinz

    Mackinz The Waste of Time

    Cool. Neither am I. Thankfully, modding Starbound uses neither. At most, you'll have to use lua scripts, but those are reportedly easy to learn given time so...
     
    Relten likes this.
  5. KingLazarus

    KingLazarus Void-Bound Voyager

    what do you mean I would have to use iua?
     
  6. Mackinz

    Mackinz The Waste of Time

    Lua.

    https://en.wikipedia.org/wiki/Lua_(programming_language)

    It's used for scripting, for advanced Starbound modding.

    An example lua script (Boat.lua):

    Code:
    require "/scripts/vec2.lua"
    require "/scripts/util.lua"
    
    function init()
      self.specialLast = false
      self.rockingTimer = 0
      self.facingDirection = 1
      self.angle = 0
      animator.setParticleEmitterActive("bubbles", false)
      self.damageEmoteTimer = 0
      self.spawnPosition = mcontroller.position()
    
      self.maxHealth =1
      self.maxBuoyancy =1
      self.waterFactor=0 --how much water are we in right now
    
      self.rockingInterval = vehicle.configParameter("rockingInterval")
      self.maxHealth = vehicle.configParameter("maxHealth")
      self.protection = vehicle.configParameter("protection")
    
      self.damageStateNames = vehicle.configParameter("damageStateNames")
      self.damageStateDriverEmotes = vehicle.configParameter("damageStateDriverEmotes")
      self.materialKind = vehicle.configParameter("materialKind")
    
    
      self.windLevelOffset = vehicle.configParameter("windLevelOffset")
      self.rockingWindAngleMultiplier = vehicle.configParameter("rockingWindAngleMultiplier")
      self.maxRockingAngle = vehicle.configParameter("maxRockingAngle")
      self.angleApproachFactor = vehicle.configParameter("angleApproachFactor")
    
      self.speedRotationMultiplier = vehicle.configParameter("speedRotationMultiplier")
    
      self.targetMoveSpeed = vehicle.configParameter("targetMoveSpeed")
      self.moveControlForce = vehicle.configParameter("moveControlForce")
    
      mcontroller.resetParameters(vehicle.configParameter("movementSettings"))
    
      self.minWaterFactorToFloat=vehicle.configParameter("minWaterFactorToFloat")
      self.sinkingBuoyancy=vehicle.configParameter("sinkingBuoyancy")
      self.sinkingFriction=vehicle.configParameter("sinkingFriction")
    
      self.bowWaveParticleNames=vehicle.configParameter("bowWaveParticles")
      self.bowWaveMaxEmissionRate=vehicle.configParameter("bowWaveMaxEmissionRate")
    
      self.splashParticleNames=vehicle.configParameter("splashParticles")
      self.splashEpsilon=vehicle.configParameter("splashEpsilon")
    
      self.maxGroundSearchDistance = vehicle.configParameter("maxGroundSearchDistance")
    
      local bounds = mcontroller.localBoundBox()
      self.frontGroundTestPoint={bounds[1],bounds[2]}
      self.backGroundTestPoint={bounds[3],bounds[2]}
    
      --setup the store functionality
      self.ownerKey = vehicle.configParameter("ownerKey")
      vehicle.setPersistent(self.ownerKey)
    
      message.setHandler("store", function(_, _, ownerKey)
    
                            local animState=animator.animationState("base")
    
                            if (animState=="idle" or animState=="sinking" or animState=="sunk") then
                              if (self.ownerKey and self.ownerKey == ownerKey) then
                                 self.spawnPosition = mcontroller.position()
                                animator.setAnimationState("base", "warpOutPart1")
                                local localStorable = (self.driver ==nil)
                                return {storable = true, healthFactor = storage.health / self.maxHealth}
                              end 
                            end
      end)
    
    --assume maxhealth
      if (storage.health) then
        animator.setAnimationState("base", "idle")   
      else
        local startHealthFactor = vehicle.configParameter("startHealthFactor")
    
        if (startHealthFactor == nil) then
            storage.health = self.maxHealth
        else
           storage.health = math.min(startHealthFactor * self.maxHealth, self.maxHealth)
        end   
        animator.setAnimationState("base", "warpInPart1") 
      end
    
      --set up any damage efects we have...
      updateDamageEffects(0, true)
    
    
    end
    
    function update()
      local sinkAngle=-math.pi*0.4
    
      local animState=animator.animationState("base")
      local waterFactor = mcontroller.liquidPercentage();
    
    
      if (animState=="warpedOut") then
        vehicle.destroy()
      elseif (animState=="warpInPart1" or animState=="warpOutPart2") then
        world.debugText("warping",mcontroller.position(),"red")
    
        --lock it solid whilst spawning/despawning
        mcontroller.setPosition(self.spawnPosition)
        mcontroller.setVelocity({0,0})
      elseif (animState=="sunk") then
    --    world.debugText("sunk",mcontroller.position(),"red")
        -- not much here.
        local targetAngle=calcGroundCollisionAngle(self.maxGroundSearchDistance)
        self.angle = self.angle + (targetAngle - self.angle) * self.angleApproachFactor
    
      elseif (animState=="sinking") then
        world.debugText("sinking",mcontroller.position(),"red")
        self.angle=updateSinking(waterFactor, self.angle,sinkAngle)
    
      elseif (animState=="idle") then
    
        world.debugText("idle",mcontroller.position(),"green")
    
        local healthFactor = storage.health / self.maxHealth
        local waterSurface = self.maxGroundSearchDistance
        self.waterBounds=mcontroller.localBoundBox()
    
        --work out water surface
        if (waterFactor>0) then
          waterSurface=(self.waterBounds[4] * waterFactor) + (self.waterBounds[2] * (1.0-waterFactor))
        end
    
        self.waterBounds[2] = waterSurface +0.25
        self.waterBounds[4] = waterSurface +0.5
    
        world.debugText(string.format("WaterSurface=%s", self.waterBounds[2]),mcontroller.position(),"yellow")
    
    
        local facing
        local moving
    
        moving,facing = updateDriving()
    
        --Rocking in the wind, and rotating up when moving
        local floating = updateFloating(waterFactor, moving,facing)
        updateMovingEffects(floating,moving)
        updatePassengers(healthFactor)
    
        if storage.health<=0 then
          vehicle.setLoungeEnabled("titanicPose",false)
          animator.setAnimationState("base", "sinking")
        end
    
        self.facingDirection = facing
        self.waterFactor=waterFactor --how deep are we in the water right now ?
      end
    
      --take care of rotating and flipping
      animator.resetTransformationGroup("flip")
      animator.resetTransformationGroup("rotation")
    
    
      if self.facingDirection < 0 then
        animator.scaleTransformationGroup("flip", {-1, 1})
      end
    
      animator.rotateTransformationGroup("rotation", self.angle)
    
      mcontroller.setRotation(self.angle)
    
    end
    
    
    
    function updateDriving()
      local moving = false
      local facing = self.facingDirection
    
      local driverThisFrame = vehicle.entityLoungingIn("drivingSeat")
      if (driverThisFrame ~= nil) then
        vehicle.setDamageTeam(world.entityDamageTeam(driverThisFrame))
    
        if vehicle.controlHeld("drivingSeat", "left") then
          mcontroller.approachXVelocity(-self.targetMoveSpeed, self.moveControlForce)
          moving = true
          facing = -1
        end
    
        if vehicle.controlHeld("drivingSeat", "right") then
          mcontroller.approachXVelocity(self.targetMoveSpeed, self.moveControlForce)
          moving = true
          facing = 1
        end
      else
        vehicle.setDamageTeam({type = "passive"})
      end
    
      return moving,facing
    end
    
    function updateSinking(waterFactor, currentAngle, sinkAngle)
    
      if (mcontroller.onGround()) then
        --not floating any more. Must have touched bottom.
        animator.setAnimationState("base", "sunk") 
    
        animator.setParticleEmitterActive("bubbles", false)
        vehicle.setLoungeEnabled("drivingSeat",false)
    
        local targetAngle=calcGroundCollisionAngle(self.maxGroundSearchDistance)
        currentAngle = currentAngle + (targetAngle - currentAngle) * self.angleApproachFactor
      else
        if (waterFactor> self.minWaterFactorToFloat) then
          if (currentAngle~=sinkAngle) then
    
            currentAngle = currentAngle + (sinkAngle - currentAngle) * self.angleApproachFactor
    
            local lerpFactor=math.cos(currentAngle)
            local finalBuoyancy=(self.maxBuoyancy * lerpFactor) + (self.sinkingBuoyancy* (1.0-lerpFactor))
            mcontroller.applyParameters({ liquidBuoyancy=finalBuoyancy,
                                          liquidFriction=self.sinkingFriction,
                                          frictionEnabled=true})
          end
          animator.setParticleEmitterActive("bubbles", true)
        end
      end
    
      return currentAngle
    end
    
    function updateFloating(waterFactor, moving, facing)
      local floating = waterFactor > self.minWaterFactorToFloat
    
      local targetAngle=0
    
      if (floating) then
        self.rockingTimer = self.rockingTimer + script.updateDt()
        if self.rockingTimer > self.rockingInterval then
    --      self.rockingTImer = self.rockingTimer - self.rockingInterval
          self.rockingTimer = self.rockingTimer - self.rockingInterval--lpk:bugfix:misCAP TImer->Timer
        end
    
        local speedAngle = mcontroller.xVelocity() * self.speedRotationMultiplier
    
        local windPosition = vec2.add(mcontroller.position(), self.windLevelOffset)
        local windLevel = world.windLevel(windPosition)
    --    local windMaxAngle = self.rockingWindAngleMultiplier * windLevel
        local windMaxAngle = math.max(self.rockingWindAngleMultiplier * windLevel, self.maxRockingAngle)--lpk:add:gently rock in no wind
        local windAngle= windMaxAngle * (math.sin(self.rockingTimer / self.rockingInterval * (math.pi * 2)))
    
    --    targetAngle = windMaxAngle + speedAngle
        targetAngle = windAngle + speedAngle--lpk:bugfix:wrong wind angle parameter
      else
        targetAngle=calcGroundCollisionAngle(self.waterBounds[2]) --pass in the water surtface
      end
    
      self.angle = self.angle + (targetAngle - self.angle) * self.angleApproachFactor
    
      
      if waterFactor > (self.waterFactor + self.splashEpsilon) then
        local floatingLiquid=mcontroller.liquidId()
    
        if (floatingLiquid>0 and  floatingLiquid<=#self.splashParticleNames) then
          local splashEmitter=self.splashParticleNames[floatingLiquid]
    
          animator.setParticleEmitterOffsetRegion(splashEmitter,self.waterBounds)
    
          animator.burstParticleEmitter(splashEmitter)
        end
      end
      return floating
    end
    
    
    
    function updateMovingEffects(floating,moving)
      if moving then
        animator.setAnimationState("propeller", "turning")
    
        if floating then
          local floatingLiquid=mcontroller.liquidId()
    
          if (floatingLiquid>0 and  floatingLiquid<=#self.bowWaveParticleNames) then
            local bowWaveEmitter=self.bowWaveParticleNames[floatingLiquid]
    
            local rateFactor=math.abs(mcontroller.xVelocity())/self.targetMoveSpeed
            rateFactor=rateFactor * self.bowWaveMaxEmissionRate   
            animator.setParticleEmitterEmissionRate(bowWaveEmitter, rateFactor)
    
            local bowWaveBounds=self.waterBounds
    --        bowWaveBounds[3]=bowWaveBounds[1]-0.5
            animator.setParticleEmitterOffsetRegion(bowWaveEmitter,bowWaveBounds)
    
            animator.setParticleEmitterActive(bowWaveEmitter, true)       
          end
        end
    
      else
        animator.setAnimationState("propeller", "still")
        for i, emitter in ipairs(self.bowWaveParticleNames) do
           animator.setParticleEmitterActive(emitter, false)
        end
      end
    end
    
    
    
    --make the driver emote according to the damage state of the vehicle
    function updatePassengers(healthFactor)
      if healthFactor >= 0 then
        --if we have a scared face on becasue of taking damage
        if self.damageEmoteTimer > 0 then
          self.damageEmoteTimer = self.damageEmoteTimer - script.updateDt()
          if (self.damageEmoteTimer < 0) then
            maxDamageState = #self.damageStateDriverEmotes
            damageStateIndex = maxDamageState
            damageStateIndex = (maxDamageState - math.ceil(healthFactor * maxDamageState))+1
            vehicle.setLoungeEmote("drivingSeat",self.damageStateDriverEmotes[damageStateIndex])
          end
        end
      end
    end
    
    
    function applyDamage(damageRequest)
      local damage = 0
      if damageRequest.damageType == "Damage" then
        damage = damage + root.evalFunction2("protection", damageRequest.damage, self.protection)
      elseif damageRequest.damageType == "IgnoresDef" then
        damage = damage + damageRequest.damage
      else
        return
      end
    
      updateDamageEffects(damage, false)
      storage.health = storage.health - damage
    
      return {{
        sourceEntityId = damageRequest.sourceEntityId,
        targetEntityId = entity.id(),
        position = mcontroller.position(),
        damage = damage,
        hitType = "Hit",
        damageSourceKind = damageRequest.damageSourceKind,
        targetMaterialKind = self.materialKind,
        killed = storage.health <= 0
      }}
    end
    
    function setDamageEmotes()
      local damageTakenEmote=vehicle.configParameter("damageTakenEmote")
      self.damageEmoteTimer=vehicle.configParameter("damageEmoteTime")
      vehicle.setLoungeEmote("drivingSeat",damageTakenEmote)
    end
    
    
    function updateDamageEffects(damage, initialise)
      local maxDamageState = #self.damageStateNames
      local healthFactor = (storage.health-damage) / self.maxHealth
      local prevhealthFactor = storage.health / self.maxHealth
    
      local prevDamageStateIndex =util.clamp( maxDamageState - math.ceil(prevhealthFactor * maxDamageState)+1, 1, maxDamageState)
      self.damageStateIndex =util.clamp( maxDamageState - math.ceil(healthFactor * maxDamageState)+1, 1, maxDamageState)
    
      if ((self.damageStateIndex > prevDamageStateIndex) or initialise==true) then
        animator.setGlobalTag("damageState", self.damageStateNames[self.damageStateIndex])
    
        --change the floatation
        local settingsNameList=vehicle.configParameter("damageMovementSettingNames")
        local settingsObject = vehicle.configParameter(settingsNameList[self.damageStateIndex])
    
        --self.maxBuoyancy =mcontroller.parameters.liquidBuoyancy()
        self.maxBuoyancy = 1
    
        mcontroller.applyParameters(settingsObject)
      end
    
      if (self.damageStateIndex > prevDamageStateIndex) then
         --people in the vehicle change thier faces when the vehicle is damaged.
        setDamageEmotes(healthFactor)
    
        --burstparticles.
        animator.burstParticleEmitter("damageShards")
        animator.playSound("changeDamageState")
      end
    end
    
    function calcGroundCollisionAngle(waterSurface)
    
      local frontDistance = math.min(distanceToGround(self.frontGroundTestPoint),waterSurface)
      local backDistance = math.min(distanceToGround(self.backGroundTestPoint),waterSurface)
    
    
    --   world.debugText(string.format("front=%s, back=%s",frontDistance,backDistance),mcontroller.position(),"yellow")
    
    
      if frontDistance == self.maxGroundSearchDistance and backDistance == self.maxGroundSearchDistance then
          return 0
      else
        local groundAngle=-math.atan(backDistance - frontDistance)
    
        return groundAngle
      end
    end
    
    function distanceToGround(point)
      -- to worldspace
      point = vec2.rotate(point, self.angle)
      point = vec2.add(point, mcontroller.position())
    
      local endPoint = vec2.add(point, {0, -self.maxGroundSearchDistance})
      local intPoint = world.lineCollision(point, endPoint)
    
      if intPoint then
        world.debugPoint(intPoint, {255, 255, 0, 255})
        return point[2] - intPoint[2]
      else
        world.debugPoint(endPoint, {255, 0, 0, 255})
        return self.maxGroundSearchDistance
      end
    
    end
    
     
    Relten likes this.
  7. Errors4l

    Errors4l Spaceman Spiff

    No, you do not. The simple config tweak I posted should suffice. If you can't get it to work feel free to reply back!
     
  8. lazarus78

    lazarus78 The Waste of Time

    The json format that starbound uses for most everything is not "code". It is more like configuration. Not that it doesn't require some thinking to understand, but there are no logic statements or anything like that.

    Most things can be worked out just by reverse engineering existing things. That's what I've done for most everything I've done.
     
  9. KingLazarus

    KingLazarus Void-Bound Voyager

    unfortunately my game has a problem. So I downloaded an auto unpacker from this site. Unpacked it and went straight for the defaultparameters.config. I copied it to the mod folder and proceeded to change the block placement radius and the defaultmax stack . I hit save and it said if I did that it could make the file unusable. So I added to the name after .config ".patch" then it saved without the warning. So I try to boot up the game and it says instead of an error for the money script it now says that the defaultmax stack has an error. So I changed it back to 1000. Well after I did this I saved and tried to run the game and it gave me exactly the same error. So I deleted the file and the game booted up just fine. So I went into the core file in the assests/items folder and found the defaultparamenters.config again and changed it to the new parameters in those two areas. The game booted up but it changed nothing! So next I took that mod I listed above's file and I copy and pasted exactly what was in the defaultparameters.config file into it to redo the coding. Long story short on that it didn't work. Either a money problem or stack problem. So I tried he code that you posted and it did nothing at all. I tried various ways of changing the texts to see if it would work. Nope nothing worked to effect in game. Eventually I accidentally copy saved over the original defaultparameters.config file with the mods file by accident. I then deleted the file and unpacked again. Yet the unpack is giving me only what is in the mod file and not the original. so I deleted it all again and not the unpack won't give me a defaultparameters.config file no matter what I do! SO I need someone with a defaultparameters.config file to post it here so I can remake it :( for Starbound.

    My game still plays perfect. But now hardcore more new characters won't start. They can't boot up the terminal for the first quest (at least for the avian side of hardcore). But my save file for my Apex works fine still. Anyway can I get you to write the entire script out here so I can copy post it into a mod so I can change the block radius? I am not interested in the stack sizes. And I need a new defaultparameters.config file (original unmodded one) too.
     
  10. Errors4l

    Errors4l Spaceman Spiff

    Unpacking the assets creates copies of everything in the packed file. Altering the unpacked files does not affect the content of the packed assets, so if you're unpacking the assets correctly it will give you a copy of the original file.
    If it doesn't, try unpacking the assets to a different location. If this is the case, I'm assuming the unpacker doesn't overwrite files.

    What was the error related to the default max stack parameter? Could you do the same thing you did before that caused the error and post your starbound.log after the game crashes?
     
  11. Mackinz

    Mackinz The Waste of Time

    And this is where you learn how to use starbound.log to debug your errors. The starbound.log file found within .../Starbound/giraffe_storage/ logs any errors your last session of the game generated, and is perhaps the modders most important tool. Open it in any text document program (I recommend one with a Reload feature, like Notepad++) and read it. Look out for any errors, as they may include json parsing errors or other issues.
     
  12. KingLazarus

    KingLazarus Void-Bound Voyager

    its exactly the same as the money one accept with the word changed to defaultstack max
     
  13. Errors4l

    Errors4l Spaceman Spiff

    The log shows more information than the error pop-up does, and without it you're probably not going to be able to find out what's wrong. Please read Mackinz last reply.
     
  14. KingLazarus

    KingLazarus Void-Bound Voyager

    well no matter what I do it will not regenerate a defaultparameters.config file. I need someone to post their unedited version from the items folder of the assets and post it here so I can copy it.
     
  15. Errors4l

    Errors4l Spaceman Spiff

     
    Relten likes this.
  16. Mackinz

    Mackinz The Waste of Time

    If you delete your old unpacked assets file and unpack it again, a new one will be generated.
     
    Relten likes this.
  17. KingLazarus

    KingLazarus Void-Bound Voyager

    already did that and it didn't give me a new one!
     
  18. Mackinz

    Mackinz The Waste of Time

    Do it again, and make sure to let the unpacker finish by itself.
     
  19. KingLazarus

    KingLazarus Void-Bound Voyager

    I've done it about 10 times already
     
  20. lazarus78

    lazarus78 The Waste of Time

    Then you are doing it wrong.

    Delete the old unpacked assets and run the unpacker just as you did the first time.
     

Share This Page