Lumina Posted July 15, 2017 Share Posted July 15, 2017 I just want to make an item that, when used, make something spawn on the map then disappears. But i don't find any item to use as a model. Instruments use a "play" function, healing items an "healing" component, and map scroll a maprecorder component. I don't see a basic item involving no anim but where i can put a custom function to use. I'm probably missing some obvious example, but i would appreciate any help to point me in the right direction. Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/ Share on other sites More sharing options...
ZupaleX Posted July 15, 2017 Share Posted July 15, 2017 (edited) Don't want to make commercial for my mod, but you can check the arrows from my Archery Mod. When you right click on them in your inventory they are transferred to a custom container. I believe that's the kind of thing you mean by "use from inventory"? EDIT: I realized you asked for a "basic item" so you probably don't want to involve custom components? Edited July 15, 2017 by ZupaleX Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939444 Share on other sites More sharing options...
Lumina Posted July 15, 2017 Author Share Posted July 15, 2017 Yeah, i mean right click, like you can do for food and healing items and this kind of stuff, or even some staff/music instruments (you right click, you do your custom action), but the closest at the moment would be the staffes and i'm not sure it's a "clean" way to manage it. It's not i'm against a custom component, but it feel like using big solution for what seems to me a "tiny" problem. Maybe it's not so tiny ? Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939448 Share on other sites More sharing options...
ZupaleX Posted July 15, 2017 Share Posted July 15, 2017 (edited) Well you either need to add a custom action to your object or hack an already existing one. I am saying stuffs without thinking too much about it so it might not work, but the first thing I would try would be to take an existing component like the instrument and try to see if you can hack the play action. There is probably a function OnPlay which you could override for your item. Like in your prefab instantiation function inst:AddComponent("instrument") inst.components.instrument.OnPlay = function(...) [...] end I don't even know if this function exists but there must be something similar. EDIT: I checked quickly the instrument.lua You could override it like that local function MyOnPlayFn(inst, player) [... Do your stuff ...] end local function myprefab_fn() [... Classic Stuffs ...] inst:AddComponent("instrument") inst.components.instrument:SetOnPlayedFn(MyOnPlayFn) inst.components.instrument.Play = function(self, player) self.onplayed(self.inst, player) return true end return inst end Totally untested and written in 2min so comes with no warranties Edited July 15, 2017 by ZupaleX Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939450 Share on other sites More sharing options...
Lumina Posted July 15, 2017 Author Share Posted July 15, 2017 Ok, i'll do tests, thank. I will probably take another look at staffes since i think i'm a little more accustomed to their code, but i keep your hack in mind if this doesn't work. Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939455 Share on other sites More sharing options...
ZupaleX Posted July 15, 2017 Share Posted July 15, 2017 Well I picked a random component which has an action from right clicking in the inventory but the instruments are not the only one and any other component allowing that would work as well Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939463 Share on other sites More sharing options...
Lumina Posted July 15, 2017 Author Share Posted July 15, 2017 Yes, i'm just more familiar with staff. Seems to be working, i just have to make the function working properly. Thanks for your help Link to comment https://forums.kleientertainment.com/forums/topic/80625-how-to-make-an-item-usable-in-inventory/#findComment-939471 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