KurtBlancaflor Posted August 12, 2015 Share Posted August 12, 2015 Hello, My friends and I are trying to make ourselves in game. We've used the extended sample character template to get ourselves in game, but we have no knowledge to update our characters any further beyond changing things like running/walking speed and hunger/health/sanity capacity! I could also change the drain rate on our hunger/health/sanity by looking at examples but then I would be too tempted to just take from other people's code. I couldn't find anything in the forums that just discussed component utilization basics, so maybe someone could give me (and any other aspiring modders) a rundown? For example, lines like: inst.components.health:SetMaxHealth(100) make sense because I can find the "health.lua" file in the component files of the game. I can then find the function "SetMaxHealth" which is simple enough, but then it utilizes commands like: self.maxhealth = amount, self.currenthealth = amount which is where I start getting lost. Is there a list of these commands that we could use to help us refine our characters? Or would we just have to dive into the existing Klei code to figure this out. Being new to video game programming, it is a bit tough to figure out what each command is saying, so I can't make enough sense of each file to actually learn how I can manipulate these attributes for our characters (I know I'd break something if I even tried). So any help would be appreciated!! ~Kurt Link to comment https://forums.kleientertainment.com/forums/topic/57034-help-with-modifying-components-on-new-characters/ Share on other sites More sharing options...
Mobbstar Posted August 12, 2015 Share Posted August 12, 2015 (edited) As a general recommendation, always look for things that do similiar things and look at their code. I think you're not quite reading functions right. A function gets declared (made) somewhere, and then it can be called (used). e.g.: local myfn = function(value, something) --making --a whole bunch of code that does fancy mathematics and stuffend myfn(26,"banarnia") --using--by the way, local things can only be accessed in that file/function/block EDIT: As with anything in life that's somewhat forgiving, just try your best and learn from failure. Make sure to understand the log.txt though! It's essential for debugging. Edited August 12, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/57034-help-with-modifying-components-on-new-characters/#findComment-662841 Share on other sites More sharing options...
KurtBlancaflor Posted August 13, 2015 Author Share Posted August 13, 2015 Thanks for your reply! And oh interesting! That function explanation helps! But when I look at the "fancier" parts of the code, I hit a dead end. For example, in armor.lua there is a function that goes like: function Armor:InitCondition(amount, absorb_percent) self.condition = amount self.absorb_percent = absorb_percent self.maxcondition = amountend I get the function heading, and I assume that since it isn't declared as "local" it can be called anywhere? (Even in our character mod code)? However, what would you call "self" in relation to the function. It's not a component or a prefab is it? And is there anyway to find the modifiable aspects to "self?" Like, if I wanna to edit a certain aspect how would I even know what to call? Any insight into this area may help me to make a big breakthrough when it comes to developing this code! Link to comment https://forums.kleientertainment.com/forums/topic/57034-help-with-modifying-components-on-new-characters/#findComment-662929 Share on other sites More sharing options...
ZupaleX Posted August 21, 2015 Share Posted August 21, 2015 Self is literally self.In your example it reffers to the component "armor".If you look in the armor class constructor, you will find several of these stuffs. These are members of the class "armor". Link to comment https://forums.kleientertainment.com/forums/topic/57034-help-with-modifying-components-on-new-characters/#findComment-665231 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