Near4422 Posted February 24, 2021 Share Posted February 24, 2021 How to simply specify the character that can use the item? And add item recipe that is only avaiable for him (not global)? Link to comment Share on other sites More sharing options...
Wonderlarr Posted February 24, 2021 Share Posted February 24, 2021 Do you want others to not be able to pick it up? Or be able to use some special action on it? I can help with both, I just need to know. As for crafting, you can specify a Tag characters need to have in order to craft in AddRecipe, I believe it is the 9th argument. Link to comment Share on other sites More sharing options...
Near4422 Posted February 24, 2021 Author Share Posted February 24, 2021 25 minutes ago, TheSkylarr said: Do you want others to not be able to pick it up? Or be able to use some special action on it? I can help with both, I just need to know. As for crafting, you can specify a Tag characters need to have in order to craft in AddRecipe, I believe it is the 9th argument. Hmmm... I think other characters could pick it up if that's easier... just not be able to use it - it's weapon and tool. If it's easier it could be completely not pickable.. dunno. Makes no differace to me. Altough I think it would be harder to prevent usage than pick up at all. As it is for crafting - Yeah - now i remember. Gonna work on that Thanks! Link to comment Share on other sites More sharing options...
Wonderlarr Posted February 25, 2021 Share Posted February 25, 2021 (edited) 23 hours ago, Near4422 said: Hmmm... I think other characters could pick it up if that's easier... just not be able to use it - it's weapon and tool. If it's easier it could be completely not pickable.. dunno. Makes no differace to me. Altough I think it would be harder to prevent usage than pick up at all. As it is for crafting - Yeah - now i remember. Gonna work on that Thanks! Oh, sorry I guess I forgot to respond haha, the custom items in my character mod are only able to be picked up by my character, I pasted this inside the OnEquip code for the items I wanted to limit, make sure to paste it ABOVE the already existing code. Also, be sure to customize the TAG part, and of course whatever lines you want. if not owner:HasTag("TAG") then --Replace TAG with a tag only your character has inst:DoTaskInTime(0, function() if owner:HasTag("player") then owner.components.inventory:DropItem(inst) --Drops the item if they don't have the above TAG if owner:HasTag("mime") then owner.components.talker:Say("") --Nothing, mimes aren't able to talk elseif owner.prefab=="wx78" then owner.components.talker:Say("ERROR: READ-ONLY ITEM") --Custom WX line, he is a robot. elseif owner.prefab=="wilbur" then owner.components.talker:Say("Ooo")-- Wilbur is monkee else owner.components.talker:Say("I can't pick that up!")-- Generic line return end end) return end Edited February 25, 2021 by TheSkylarr Link to comment Share on other sites More sharing options...
Near4422 Posted February 25, 2021 Author Share Posted February 25, 2021 Hmm... for some reason this code doesn't allow me even compile the mod. I get error whenever i try to launch a server :c local function onequip(inst, owner) local owner = inst.components.inventoryitem.owner or nil if not owner:HasTag("scarecrow") then --Replace TAG with a tag only your character has inst:DoTaskInTime(0, function() if owner:HasTag("player") then owner.components.inventory:DropItem(inst) --Drops the item if they don't have the above TAG if owner:HasTag("mime") then owner.components.talker:Say("") --Nothing, mimes aren't able to talk elseif owner.prefab=="wx78" then owner.components.talker:Say("ERROR: READ-ONLY ITEM") --Custom WX line, he is a robot. elseif owner.prefab=="wilbur" then owner.components.talker:Say("Ooo")-- Wilbur is monkee else owner.components.talker:Say("I can't pick that up!")-- Generic line return end end) return end owner.AnimState:OverrideSymbol("swap_object", "swap_scare_scythe", "scare_scythe") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end I've literarly this code above. Uhm... nevermind... i've been impatient... I just cut the code for the custom character lines and it worked.. weird but... I am fine with that.... Thank you for your time! Link to comment Share on other sites More sharing options...
Wonderlarr Posted February 26, 2021 Share Posted February 26, 2021 48 minutes ago, Near4422 said: Hmm... for some reason this code doesn't allow me even compile the mod. I get error whenever i try to launch a server :c local function onequip(inst, owner) local owner = inst.components.inventoryitem.owner or nil if not owner:HasTag("scarecrow") then --Replace TAG with a tag only your character has inst:DoTaskInTime(0, function() if owner:HasTag("player") then owner.components.inventory:DropItem(inst) --Drops the item if they don't have the above TAG if owner:HasTag("mime") then owner.components.talker:Say("") --Nothing, mimes aren't able to talk elseif owner.prefab=="wx78" then owner.components.talker:Say("ERROR: READ-ONLY ITEM") --Custom WX line, he is a robot. elseif owner.prefab=="wilbur" then owner.components.talker:Say("Ooo")-- Wilbur is monkee else owner.components.talker:Say("I can't pick that up!")-- Generic line return end end) return end owner.AnimState:OverrideSymbol("swap_object", "swap_scare_scythe", "scare_scythe") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end I've literarly this code above. Uhm... nevermind... i've been impatient... I just cut the code for the custom character lines and it worked.. weird but... I am fine with that.... Thank you for your time! Nice to see you got it working, just so you know, OnEquip already knows the owner of the item automatically, no need to define owner again like you've done with local owner = inst.components.inventoryitem.owner or nil 1 Link to comment Share on other sites More sharing options...
Ultroman Posted March 1, 2021 Share Posted March 1, 2021 (edited) Just for future reference, the post linked below explains how to make character-specific recipes and making an item like Thor's Hammer which can only be picked up by your character. Deceptively simple. Handling it in OnEquip (like the posts above) gives more flexibility, in that you can ask a friend to bring the item to you, but if the item is usable or equippable, then you could have some complex stuff to handle about who can use it etc.. If your use-case is pretty simple, which it seems this OPs is, the examples above are just fine. Edited March 1, 2021 by Ultroman Link to comment Share on other sites More sharing options...
asvinh Posted September 25, 2021 Share Posted September 25, 2021 On 3/1/2021 at 2:32 PM, Ultroman said: Just for future reference, the post linked below explains how to make character-specific recipes and making an item like Thor's Hammer which can only be picked up by your character. Deceptively simple. Handling it in OnEquip (like the posts above) gives more flexibility, in that you can ask a friend to bring the item to you, but if the item is usable or equippable, then you could have some complex stuff to handle about who can use it etc.. If your use-case is pretty simple, which it seems this OPs is, the examples above are just fine. Using that guide for How to make it so no one else can pick up a custom item, like Thor's hammer? I can't seem to Generate my world when I put in that line. "Dedicated Server Failed To Start - There was some sort of trouble starting the server. Please try again. handitem.lua Link to comment Share on other sites More sharing options...
Ultroman Posted September 26, 2021 Share Posted September 26, 2021 (edited) 19 hours ago, asvinh said: Using that guide for How to make it so no one else can pick up a custom item, like Thor's hammer? I can't seem to Generate my world when I put in that line. "Dedicated Server Failed To Start - There was some sort of trouble starting the server. Please try again. handitem.lua 2.6 kB · 0 downloads That makes sense, since you've pasted the code in after the "return inst" line, which completes the fn() function. Edited September 26, 2021 by Ultroman Link to comment Share on other sites More sharing options...
asvinh Posted September 26, 2021 Share Posted September 26, 2021 Ahh okay, now I don't crash after placing it above return, however only the speech line works. Other characters will say the line they cant wield that but they still equip it anyway 5 hours ago, Ultroman said: That makes sense, since you've pasted the code in after the "return inst" line, which completes the fn() function. Link to comment Share on other sites More sharing options...
Ultroman Posted September 27, 2021 Share Posted September 27, 2021 20 hours ago, asvinh said: Ahh okay, now I don't crash after placing it above return, however only the speech line works. Other characters will say the line they cant wield that but they still equip it anyway Hmm...not sure what could be wrong. Perhaps they changed the way the code works in the game. I don't have time to find the solution atm. 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