So I've created an item, a new stimpack that is supposed to, on consumption/use, spawn an item. The lua doesn't quite work, but it is also supposed to take health away for a bit of time after spawning the item (which I took four different attempts at) Now I will confess I know little to nothing of lua, C# is my thing, so any tips on how I can get this goin? Here is the lua of the stim statuseffect (soulsiphon.lua) Code: function init() script.setUpdateDelta(5) self.tickDamagePercentage = 0.05 self.tickTime = 0.2 self.tickTimer = self.tickTime damage = 10 end function update(dt) player.giveItem("soulessence", 1), world.spawnItem("soulessence", entity.position(), 1) self.tickTimer = self.tickTimer - dt if self.tickTimer <= 0 then self.tickTimer = self.tickTime status.applySelfDamageRequest({ damageType = "IgnoresDef", damage = math.floor(status.resourceMax("health") * self.tickDamagePercentage) + 1, damageSourceKind = "fire", sourceEntityId = entity.id() }) player.giveItem("soulessence", 1) world.spawnItem("soulessence", entity.position(), 1) end effect.setParentDirectives(string.format("fade=00AA00=%.1f", self.tickTimer * 0.4)) end function uninit() end
i look at the redstim item , then i discover a file redstim.statuseffect the code in it is Starbound Assets/stats/effects/regeneration/ Code: { "name" : "redstim", "blockingStat" : "healingStatusImmunity", "effectConfig" : { "healTime" : 30 }, "defaultDuration" : 60, "scripts" : [ "regeneration.lua" /// MAYBE IF WE ADD CUSTOM SCRIPT HERE example stimloot.lua ], "animationConfig" : "regeneration.animation", "label" : "Regeneration", "icon" : "/interface/statuses/heal.png" } wheres is wrote "script" is the field where you can add or remove script maybe you can add a custumize script to it. Theres also Starbound Assets/items/active/unsorted/rewardbag theres a file called rewardbag.lua that you can maybe use as a template for your script the rewardbag its the most near item for your idea heres the script of rewardbag.lua: Code: require "/scripts/vec2.lua" function init() self.recoil = 0 self.recoilRate = 0 self.fireOffset = config.getParameter("fireOffset") updateAim() self.active = false storage.fireTimer = storage.fireTimer or 0 end function update(dt, fireMode, shiftHeld) updateAim() storage.fireTimer = math.max(storage.fireTimer - dt, 0) if self.active then self.recoilRate = 0 else self.recoilRate = math.max(1, self.recoilRate + (10 * dt)) end self.recoil = math.max(self.recoil - dt * self.recoilRate, 0) if self.active and not storage.firing and storage.fireTimer <= 0 then self.recoil = math.pi/2 - self.aimAngle activeItem.setArmAngle(math.pi/2) if animator.animationState("firing") == "off" then animator.setAnimationState("firing", "fire") end storage.fireTimer = config.getParameter("fireTime", 1.0) storage.firing = true end self.active = false if storage.firing and animator.animationState("firing") == "off" then item.consume(1) if player then local pool = config.getParameter("treasure.pool") local level = config.getParameter("treasure.level") local seed = config.getParameter("treasure.seed") local treasure = root.createTreasure(pool, level, seed) for _,item in pairs(treasure) do player.giveItem(item) end end storage.firing = false return end end function activate(fireMode, shiftHeld) if not storage.firing then self.active = true end end function updateAim() self.aimAngle, self.aimDirection = activeItem.aimAngleAndDirection(self.fireOffset[2], activeItem.ownerAimPosition()) self.aimAngle = self.aimAngle + self.recoil activeItem.setArmAngle(self.aimAngle) activeItem.setFacingDirection(self.aimDirection) end function firePosition() return vec2.add(mcontroller.position(), activeItem.handPosition(self.fireOffset)) end function aimVector() local aimVector = vec2.rotate({1, 0}, self.aimAngle + sb.nrand(config.getParameter("inaccuracy", 0), 0)) aimVector[1] = aimVector[1] * self.aimDirection return aimVector end function holdingItem() return true end function recoil() return false end function outsideOfHand() return false end