PanAzej Posted February 17, 2016 Share Posted February 17, 2016 I've made a follower creature that can be also picked up to inventory. The problem is, it's annoying when character picks up items using [spacebar] and the creature gets picked up as well. How to make it so an item (creature) can be picked up only with mouse-click? Link to comment https://forums.kleientertainment.com/forums/topic/64473-item-pickup-able-only-with-mouse/ Share on other sites More sharing options...
Muche Posted February 17, 2016 Share Posted February 17, 2016 Butterflies and fireflies set inst.components.inventoryitem.canbepickedup = false and make themselves the target of an action with a net with workable component. However, PlayerController:GetActionButtonAction() (together with GetPickupAction(); both in components/playercontroller.lua) makes using tools on spacebar possible as well. I guess custom mod action (that imitates pickup action) could solve that. Link to comment https://forums.kleientertainment.com/forums/topic/64473-item-pickup-able-only-with-mouse/#findComment-723726 Share on other sites More sharing options...
PanAzej Posted March 1, 2016 Author Share Posted March 1, 2016 (edited) Here's what I did, but it doesn't work. What am I missing? I haven't made custom actions for this game yet, so I have no idea what's wrong. local ATTYLAPICK = GLOBAL.Action({ priority=1 }) ATTYLAPICK.str = "Pick Up" ATTYLAPICK.id = "ATTYLAPICK" ATTYLAPICK.fn = function(act) if act.doer.components.inventory ~= nil and act.target ~= nil and act.target.components.inventoryitem ~= nil and act.target:HasTag("attyla") then act.doer:PushEvent("onpickupitem", { item = act.target }) return true end end AddAction(ATTYLAPICK) local attyla_pickhandler = ActionHandler(ACTIONS.ATTYLAPICK, "doshortaction") AddStategraphActionHandler("wilson", attyla_pickhandler) Also, I've trying to set creature's canbepickedup to false - didn't work. I can only examine it. Leaving canbepickedup as true and setting ATTYLAPICK to higher priority didn't work either - PICKUP still is used over my action, so... Obviously I'm doing something wrong here. Maybe there's some smart person that can help me. Edited March 1, 2016 by PanAzej Link to comment https://forums.kleientertainment.com/forums/topic/64473-item-pickup-able-only-with-mouse/#findComment-728714 Share on other sites More sharing options...
Muche Posted March 1, 2016 Share Posted March 1, 2016 (edited) Try adding (based on componentactions.lua/SCENE/inventoryitem) AddComponentAction("SCENE", "inventoryitem", function(inst, doer, actions, right) if inst.replica.inventoryitem:CanBePickedUp() and doer.replica.inventory ~= nil and not (inst:HasTag("catchable") or inst:HasTag("fire")) and inst:HasTag("attyla") then table.insert(actions, ACTIONS.ATTYLAPICK) end end) AddStategraphActionHandler("wilson_client", attyla_pickhandler) Also see (Component Actions part): Edited March 1, 2016 by Muche Link to comment https://forums.kleientertainment.com/forums/topic/64473-item-pickup-able-only-with-mouse/#findComment-728717 Share on other sites More sharing options...
PanAzej Posted March 1, 2016 Author Share Posted March 1, 2016 (edited) 1 hour ago, Muche said: Try adding (based on componentactions.lua/SCENE/inventoryitem) AddComponentAction("SCENE", "inventoryitem", function(inst, doer, actions, right) if inst.replica.inventoryitem:CanBePickedUp() and doer.replica.inventory ~= nil and not (inst:HasTag("catchable") or inst:HasTag("fire")) and inst:HasTag("attyla") then table.insert(actions, ACTIONS.ATTYLAPICK) end end) AddStategraphActionHandler("wilson_client", attyla_pickhandler) Also see (Component Actions part): Thank you very much! I still had to fix something, but it works perfectly now! I've set canbepickedup to false, so ATTYLAPICK and PICKUP don't overlap. Here's the final code (just in case somebody somewhere sometime would have the same problem as me): local ATTYLAPICK = GLOBAL.Action({ priority=1 }) ATTYLAPICK.str = "Pick up" ATTYLAPICK.id = "ATTYLAPICK" ATTYLAPICK.fn = function(act) if act.doer.components.inventory ~= nil and act.target ~= nil and act.target.components.inventoryitem ~= nil and act.target:HasTag("attyla") then act.doer:PushEvent("onpickupitem", { item = act.target }) act.doer.components.inventory:GiveItem(act.target, nil, act.target:GetPosition()) return true end end AddAction(ATTYLAPICK) local attyla_pickhandler = ActionHandler(ACTIONS.ATTYLAPICK, "doshortaction") AddStategraphActionHandler("wilson", attyla_pickhandler) AddComponentAction("SCENE", "inventoryitem", function(inst, doer, actions, right) if doer.replica.inventory ~= nil and inst:HasTag("attyla") and not inst:HasTag("fire") then table.insert(actions, ACTIONS.ATTYLAPICK) end end) AddStategraphActionHandler("wilson_client", attyla_pickhandler) Edited March 1, 2016 by PanAzej Link to comment https://forums.kleientertainment.com/forums/topic/64473-item-pickup-able-only-with-mouse/#findComment-728739 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