Jump to content

Recommended Posts

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

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 stuff

end

 

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 by Mobbstar

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 = amount
end
 
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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...