Jump to content

Recommended Posts

Hi

So, i'm new to the modding community, and i don't know much about modding or programming overall but i wanted to create a level up system for the character that is either a:

A) Get exp by killing mobs (and if possible get different values of exp for different types of creature).

or

B) Level up every X number of days, for example, each 5 days he gets stronger.

And i wanted to do him as a mage/fighter type of character, but as he gets higher levels he can use diferent skills and he gets a higher damage output.

 

Well, that's it, i'd really appreciate some help and sorry if i've got anything wrong, english isn't my native language.

I think what you're trying to implement might be a bit too complicated for you for now, since you're new to modding in Don't Starve. I suggest you start with something smaller. Of course, I'm not stopping you from going in deep.

For some tips I suggest you check some mods that might be similar to what you're trying to do.

Also check this thread, it has a lot of useful information:

And if you haven't already, watch some lua introducing videos or go through the basics of lua here:

https://www.lua.org/pil/contents.html

  • Like 1
  • Thanks 1

Finally i can help someone  i hope its not too late... Let me know if there is any error

 

first of all here is the level up system

local function LevelSystem(inst, data)

  local max_exp = the number you want
  local min_exp = the number you want
  local experience = math.min (inst.experience, max_exp, min_exp) 
  
  local max_level = the number you want
  local min_level = the number you want
  local level = math.min (inst.level, max_level, min_level)
  
  if inst level == 0 then
    inst.expneededforlevel = 10
  elseif inst.level = 1 then
    inst.expneededforlevel = 20
   end
  
  if inst.experience >= inst.expneededforlevel then
    inst.level = inst.level + 1
  end
end

and here is experience part you must add every creature

local function onkill (inst, data)
  
  local victim = data.victim
  
  if (
      	victim:HasTag("rabbit")
      ) then
    inst.experience = inst.experience + amount of exp that creature gives
 end
end

and for save

local function onsave(inst, data)
	data.level = inst.level
	data.experience = inst.experience
end

put those in common_postinit

inst.level = 0
inst.experience = 0

put those in master_postinit

inst.level = 0
inst.experience = 0

inst:ListenForEvent("killed", onkill)
inst:ListenForEvent("levelup", LevelSystem)

inst.OnSave = onsave
inst.OnPreLoad = onpreload

 

  • Like 3

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...