Jump to content

How to update variables


Recommended Posts

I am making a hud-like pannel for my character stats like level experience boss kill etc... Well it works fine but it does not update itself when the character level ups how i can make it check for any changes? Anyway im leaving my codes.

 

this is for my character to level up

if inst.experience >= inst.expneededforlevel then
	inst.experience = 0
	inst.SoundEmitter:PlaySound("kitsura/characters/kitsura/level up")
	inst.level = inst.level + 1
	inst.expneededforlevel = (inst.expneededforlevel * 0 + inst.level * 10)
	inst.components.talker:Say("Level Up!! Level \n".. (inst.level) )
end

and this is the screen shot of the menu

when this photo taken my character was lvl 1(i am sure he is) and he had some experience with 1 koalefant kill but none of them were updated.

1299363856_charactermenu.thumb.png.8a240e6a3b95e23e403ab89d8c8ca71f.png

i don't know how to check for if the variables are changed or not.

Link to comment
Share on other sites

51 minutes ago, CarlZalph said:

If the server has caverns then the player is a full client and won't see such updates.

Look into networked variables to pass data from the server to a client, or use the newer mod RPC interface to pass the data.

Well tbh i don't have any idea how to do that... i guess for level and other stuffs i can do it old way. (like in the stat_ui.lua i can enter some vaules depends on level so when my level changes it replaces the number etc.) but for kill count or experiences i need to find another way can't i just connect stat_ui.lua with my character.lua? is it possible? or is there any tutorials for networked variables?

Link to comment
Share on other sites

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
 Share

×
  • Create New...