SenL Posted March 22, 2015 Share Posted March 22, 2015 I have a custom item and it has a level system. I want to be able to have players inspect it and it would say "bla bla bla" then next line "(Level: 1)". How do I do that?Also how does inspectable.getstatus work... example Abigail's flower has "SOON" but the corresponding quote-content "SOON" is only in speech_wendy.lua ... what about other character? I'd like this custom item of mine to be inspectable by anyone. Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/ Share on other sites More sharing options...
DarkXero Posted March 22, 2015 Share Posted March 22, 2015 Something must be inspectable to inspect it.When you inspect it, your character will say the description of the item in question.This description depends on the viewer, the item, and the status that the item reports.The viewer selects the speech.The item, the name of the entry in the speech table.The status, the name of the entry in a table inside an entry in the speech table (so you get multiple descriptions in the same prefab). getstatus exists so you add your own statuses, because abigail's flower can't have health, sleep, wither, or occupied. Wendy has an entry on her speech, on her item, on the statuses defined.Other characters have nothing, so they say "It's a... thing.", the generic comment. Instead of editing speech files or making statuses, I suggest you use thedesc = self.descriptionfn(self.inst, viewer)part in GetDescription of the inspectable component. Like:local mylines = { wilson = "What is this?", willow = "A test."}AddPrefabPostInit("axe", function(inst) inst.level = 1 inst.components.inspectable.descriptionfn = function(inst, viewer) local desc; if mylines[viewer.prefab] then desc = mylines[viewer.prefab] else desc = "I have no lines." end desc = desc.."\n".."Level: "..inst.level return desc endend)Wilson and Willow have defined lines, others (including mod characters), get the generic one I made.I also append the item level into the description. Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/#findComment-623845 Share on other sites More sharing options...
SenL Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks that makes sense. I'll try it.However, this is what I see in inspectable.lua: desc = self.getspecialdescription(self.inst, viewer) (I'm not in RoG test) Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/#findComment-623894 Share on other sites More sharing options...
SenL Posted March 22, 2015 Author Share Posted March 22, 2015 It works. Thanks a lot. Ok new problem. Apparently this below doesn't work. It works on character...inst:ListenForEvent("entity_death", function(world, data) entitydeathfn(inst, data) end, TheWorld) I want this custom item to gain exp as the wearer kills creatures.What is the workaround? Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/#findComment-623955 Share on other sites More sharing options...
DarkXero Posted March 22, 2015 Share Posted March 22, 2015 Then, you are putting it wrong inside your prefab's fn, becauselocal function entitydeathfn(inst, data) inst.exp = inst.exp + 1 if inst.exp == 2 then inst.level = inst.level + 1 inst.exp = 0 endendAddPrefabPostInit("axe", function(inst) inst.exp = 0 inst.level = 0 inst:ListenForEvent("entity_death", function(world, data) entitydeathfn(inst, data) end, GLOBAL.TheWorld)end)works fine. Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/#findComment-623981 Share on other sites More sharing options...
SenL Posted March 22, 2015 Author Share Posted March 22, 2015 Ah yes it works. Sorry.It had "if data.cause == inst.prefab" and that broke it because data.cause is the user (ie: wilson) and inst.prefab is not wilson (it's "myhat"). Link to comment https://forums.kleientertainment.com/forums/topic/52247-inspectablegetstatus/#findComment-624011 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