I'm trying to change the behavior of a booster I made, a rocket booster. What I'm trying to do is that it doubles speed upon activation (pressing F) and pressing the primary fire (left mouse button). What happens though is that it actually loses speed mid flight. Here's the lua so far (the tech.parameter("doubleboostSpeed") is 180, by the way): Pastebin link: http://pastebin.com/PiCETUps Code: function init() data.lastJump = false data.lastBoost = nil data.ranOut = false data.active = false end function input(args) local currentJump = args.moves["jump"] local currentBoost = nil if not tech.onGround() then if not tech.canJump() and currentJump and not data.lastJump then if args.moves["right"] and args.moves["up"] then currentBoost = "boostRightUp" elseif args.moves["right"] and args.moves["down"] then currentBoost = "boostRightDown" elseif args.moves["left"] and args.moves["up"] then currentBoost = "boostLeftUp" elseif args.moves["left"] and args.moves["down"] then currentBoost = "boostLeftDown" elseif args.moves["right"] then currentBoost = "boostRight" elseif args.moves["down"] then currentBoost = "boostDown" elseif args.moves["left"] then currentBoost = "boostLeft" elseif args.moves["up"] then currentBoost = "boostUp" end elseif currentJump and data.lastBoost then currentBoost = data.lastBoost end end if args.moves["special"] == 1 then if not data.active then return "activate" else return "deactivate" end end if args.moves["primaryFire"] then return "doubleboost" end data.lastJump = currentJump data.lastBoost = currentBoost return currentBoost end function update(args) local boostControlForce = tech.parameter("boostControlForce") local boostSpeed = tech.parameter("boostSpeed") local energyUsagePerSecond = tech.parameter("energyUsagePerSecond") local energyUsage = energyUsagePerSecond * args.dt if not data.active and args.actions["activate"] then world.logInfo("activate") tech.setToolUsageSuppressed(true) data.active = true elseif data.active and args.actions["deactivate"] then world.logInfo("deactivate") tech.setToolUsageSuppressed(false) data.active = false end if data.active and args.actions["doubleboost"] then boostSpeed = tech.parameter("doubleboostSpeed") end if args.availableEnergy < energyUsage then data.ranOut = true elseif tech.onGround() or tech.inLiquid() then data.ranOut = false end if not data.active and args.actions["activate"] then world.logInfo("activate") tech.setToolUsageSuppressed(true) data.active = true elseif data.active and args.actions["deactivate"] then world.logInfo("deactivate") tech.setToolUsageSuppressed(false) data.active = false end local boosting = false local diag = 1 / math.sqrt(2) if not data.ranOut then boosting = true if args.actions["boostRightUp"] then tech.control({boostSpeed * diag, boostSpeed * diag}, boostControlForce, true, true) elseif args.actions["boostRightDown"] then tech.control({boostSpeed * diag, -boostSpeed * diag}, boostControlForce, true, true) elseif args.actions["boostLeftUp"] then tech.control({-boostSpeed * diag, boostSpeed * diag}, boostControlForce, true, true) elseif args.actions["boostLeftDown"] then tech.control({-boostSpeed * diag, -boostSpeed * diag}, boostControlForce, true, true) elseif args.actions["boostRight"] then tech.control({boostSpeed, 0}, boostControlForce, true, true) elseif args.actions["boostDown"] then tech.control({0, -boostSpeed}, boostControlForce, true, true) elseif args.actions["boostLeft"] then tech.control({-boostSpeed, 0}, boostControlForce, true, true) elseif args.actions["boostUp"] then tech.control({0, boostSpeed}, boostControlForce, true, true) else boosting = false end end if boosting then tech.setAnimationState("boosting", "on") tech.setParticleEmitterActive("boostParticles", true) return energyUsage else tech.setAnimationState("boosting", "off") tech.setParticleEmitterActive("boostParticles", false) return 0 end end
I already tried: boostSpeed = boostSpeed + 100 boostSpeed = boostSpeed * 2 boostSpeed = tech.parameter("boostSpeed") * 2 And so forth. All they do is make the boost slow down and/or stop.