MF99K Posted May 7, 2016 Share Posted May 7, 2016 (edited) Hi everyone. For a while now I've been working on a custom item. I've basically made something that puts the pick/axe to shame. However, I have a couple problems. 1. The ground animation works fine, but it's invisible when equipped. I think this is probably because I have to code animations to match with different actions, but I'm not sure. 2. I'd like to be able to make it toggleable. as in, it has a staff mode and a tool mode, that can be switched sort of like how a lantern can be turned on and off. 3. For staff mode, I would like it to be able to function as a purple or orange staff would. As in, be able to teleport objects and the character, minus the telelocator focus. so far the item already works as a sword/pick/axe/torch but I would at least like to make it not invisible anymore. Edited May 7, 2016 by mf99k Link to comment Share on other sites More sharing options...
DarkXero Posted May 8, 2016 Share Posted May 8, 2016 15 hours ago, mf99k said: 1. The ground animation works fine, but it's invisible when equipped. I think this is probably because I have to code animations to match with different actions, but I'm not sure. You gave the item the build and the swap build right? Like how spears have spear and swap_spear. Upload the weapon to see if the symbol used during in owner.AnimState:OverrideSymbol is correct. 15 hours ago, mf99k said: 2. I'd like to be able to make it toggleable. as in, it has a staff mode and a tool mode, that can be switched sort of like how a lantern can be turned on and off. local function turn_on(inst) inst:AddComponent("tool") inst:RemoveComponent("spellcaster") end local function turn_off(inst) inst:AddComponent("spellcaster") inst:RemoveComponent("tool") end inst:AddComponent("machine") inst.components.machine.turnonfn = turn_on inst.components.machine.turnofffn = turn_off inst.components.machine.cooldowntime = 0 15 hours ago, mf99k said: 3. For staff mode, I would like it to be able to function as a purple or orange staff would. As in, be able to teleport objects and the character, minus the telelocator focus. local function turn_on(inst) inst:AddComponent("tool") inst:RemoveComponent("blinkstaff") end local function turn_off(inst) inst:AddComponent("blinkstaff") inst:RemoveComponent("tool") end Link to comment Share on other sites More sharing options...
MF99K Posted May 8, 2016 Author Share Posted May 8, 2016 20 hours ago, DarkXero said: You gave the item the build and the swap build right? Like how spears have spear and swap_spear. Upload the weapon to see if the symbol used during in owner.AnimState:OverrideSymbol is correct. local function turn_on(inst) inst:AddComponent("tool") inst:RemoveComponent("spellcaster") end local function turn_off(inst) inst:AddComponent("spellcaster") inst:RemoveComponent("tool") end inst:AddComponent("machine") inst.components.machine.turnonfn = turn_on inst.components.machine.turnofffn = turn_off inst.components.machine.cooldowntime = 0 local function turn_on(inst) inst:AddComponent("tool") inst:RemoveComponent("blinkstaff") end local function turn_off(inst) inst:AddComponent("blinkstaff") inst:RemoveComponent("tool") end ok, but how would I set up the purple staff code minus the telelocator? Link to comment Share on other sites More sharing options...
Aquaterion Posted May 8, 2016 Share Posted May 8, 2016 (edited) 2 hours ago, mf99k said: ok, but how would I set up the purple staff code minus the telelocator? well if you want it to work like the purple staff, you have to know where you want to teleport since there is no telelocator as a "home" for the teleport unless you're talking about the random teleport. Edited May 8, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
MF99K Posted May 9, 2016 Author Share Posted May 9, 2016 9 hours ago, Aquaterion said: well if you want it to work like the purple staff, you have to know where you want to teleport since there is no telelocator as a "home" for the teleport unless you're talking about the random teleport. I'm talking about the random teleport Link to comment Share on other sites More sharing options...
Aquaterion Posted May 9, 2016 Share Posted May 9, 2016 local function teleport_fn(staff, target) -- random teleport function local caster = staff.components.inventoryitem.owner local validposition = false target = target or caster-- if target is nil then caster becomes the target while not validposition do local x,y,z = math.random(-1000,1000), 0, math.random(-1000,1000) if TheWorld.Map:GetTileAtPoint(x,y,z) ~= 1 and TheWorld.Map:GetTileAtPoint(x,y,z) ~= 255 then target.Transform:SetPosition(x,y,z) --staff.components.finiteuses:Use(1) validposition = true end end end --things to add to your "multitool" when changing states: inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(teleport_fn) inst.components.spellcaster.canuseontargets = true inst.components.spellcaster.canusefrominventory = true inst.components.spellcaster.canonlyuseonlocomotors = true --and when leaving the staff state: isnt:RemoveComponent("spellcaster") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now