Jump to content

How to make my components work in client?


Recommended Posts

I have designed a few components(including level,exp,skill,CD and etc.)  and UI for my character.They works well in server side.To make them work in client side ,I add these components in common_postinit function.But They don't change  the data. For example, in server side, I can click the add button to make the skill's level up to 1,but I can't do that in client side. What's more, I can't use the data such as level,exp etc which were saved in the components when I was in client side. How to solve this problem?

Link to comment
Share on other sites

 @Kzisor

Wow, excellent! I have read the code and learnt how to do.Thank you very much.  2 quetions more:

1、In your levelbadge.lua, I see the function OnUpdate. When does it fire?

I don't konw how to use it  so I use event to transfer data between UI and components, but I think your code is more concise

2、Do you know how to make a UI can be drag?I means that like items can be pick up by mouse from inventory.

I can read code, so,to save your time, you can simply tell me what file to learn.

 

PS,why don't add these code to the GUIDE? It's really useful.

Link to comment
Share on other sites

two more questions:

1、The function ListenForEvent has 3 parameters,I know how to use the first and second one,but can't understand the third one even though I read the function definition code .

2、In hunger.lua , I see the class function use 3 parameters,the second is nil and the third is a table containing some data which have been define in the first parameter,and these data is related to replica. I used to think it is important for replica, but you don't use them.So,what is their role?

Link to comment
Share on other sites

14 hours ago, LongFeiaot said:

 @Kzisor

Wow, excellent! I have read the code and learnt how to do.Thank you very much.  2 quetions more:

1、In your levelbadge.lua, I see the function OnUpdate. When does it fire?

I don't konw how to use it  so I use event to transfer data between UI and components, but I think your code is more concise

2、Do you know how to make a UI can be drag?I means that like items can be pick up by mouse from inventory.

I can read code, so,to save your time, you can simply tell me what file to learn.

 

PS,why don't add these code to the GUIDE? It's really useful.

1) OnUpdate is fired when the game engine tells it to fire.

2) I'm sorry, but I don't know if that is possible.

14 hours ago, LongFeiaot said:

two more questions:

1、The function ListenForEvent has 3 parameters,I know how to use the first and second one,but can't understand the third one even though I read the function definition code .

2、In hunger.lua , I see the class function use 3 parameters,the second is nil and the third is a table containing some data which have been define in the first parameter,and these data is related to replica. I used to think it is important for replica, but you don't use them.So,what is their role?

1) The third parameter is the instance which will be used to listen on. Look at some of 'TheWorld' code for players to understand more about it.

2) They allow the server to automatically formulate replica data on the client side, I don't use them because they are not entirely needed.

Link to comment
Share on other sites

On 18. 3. 2016 at 9:35 AM, LongFeiaot said:

2、Do you know how to make a UI can be drag?I means that like items can be pick up by mouse from inventory.

Enable attached client mod. In the main menu a small rectangle will appear that can be dragged around.

modmain.lua

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