Can you use arguments with this.setClientState?

Game development with Board Game Arena Studio
Post Reply
VanHlebar
Posts: 26
Joined: 24 September 2019, 02:30

Can you use arguments with this.setClientState?

Post by VanHlebar » 02 December 2019, 21:16

I am transitioning to a clientState and I would like to be able to use an argument in my description. Is this possible? I have tried the following but it keeps giving me an error:

Code: Select all

 this.setClientState("client_PlayerPlaceCaballeros", {
 	descriptionmyturn : _("${you} may place ${cabs_to_move} caballeros on the board."), 
        cabs_to_move : this.clientStateArgs.cabs_avail_to_move
});
The javascript error I get is the following:
Invalid or missing substitution argument for log message: ${you} may place ${cabs_to_move} caballeros on the board.

User avatar
tchobello
Posts: 138
Joined: 18 March 2012, 13:19

Re: Can you use arguments with this.setClientState?

Post by tchobello » 02 December 2019, 21:47

hi !

You should have a look at the complete description of States ( and use 'args' line)...

http://en.doc.boardgamearena.com/Your_g ... es.inc.php

VanHlebar
Posts: 26
Joined: 24 September 2019, 02:30

Re: Can you use arguments with this.setClientState?

Post by VanHlebar » 02 December 2019, 22:30

I did look at that and tried to follow that, however this is on the client side so I wasn't sure if the same theory held true. I am not going back to the server at this stage as there is no need to do so yet.

I was trying to follow the example in the Cookbook area of the documentation but since this.setClientState is undocumented, I was unable to see if using variables like this is even valid.

Thanks,
Eric

User avatar
hersh
Posts: 7
Joined: 12 December 2013, 23:49

Re: Can you use arguments with this.setClientState?

Post by hersh » 03 December 2019, 05:42

try using the parameter named "args"

Code: Select all

this.setClientState("client_PlayerPlaceCaballeros", {
 	descriptionmyturn : _("${you} may place ${cabs_to_move} caballeros on the board."), 
        args: this.clientStateArgs        <------- make sure this object has "cabs_to_move" property defined
});

vincentt
Posts: 112
Joined: 01 September 2017, 17:25

Re: Can you use arguments with this.setClientState?

Post by vincentt » 03 December 2019, 12:39

Hi,

I concur you need to use args.
You can look at DiceForge code, we use some and we use the args parameters :)

Vincent

VanHlebar
Posts: 26
Joined: 24 September 2019, 02:30

Re: Can you use arguments with this.setClientState?

Post by VanHlebar » 03 December 2019, 13:13

Awesome thanks for the direction folks I appreciate it!

vincentt
Posts: 112
Joined: 01 September 2017, 17:25

Re: Can you use arguments with this.setClientState?

Post by vincentt » 03 December 2019, 23:58

hi,

In DF code, you will see that we have a function to go back to server state.
Also, take care to reset your variable when you go out of the client state, as it can be persistent and triggers some erratic behavior (we had some "fun" time to understand our issues)

Vincent

VanHlebar
Posts: 26
Joined: 24 September 2019, 02:30

Re: Can you use arguments with this.setClientState?

Post by VanHlebar » 04 December 2019, 03:43

Thanks for the "warning", I already had experienced some of those "interesting" times when I forgot to reset my clentStateArgs variable. :)

It just seems silly to me that I have to go back to the server just so that I can pass these args back to the the client, when I already have ALL the information I need for that specific client state. If this is the only way then so be it, but it just seems like a wasted call back to the server. I did get read access to your project and was going to poke around at it this evening or tomorrow.

Thanks again so much for the assistance!

Eric

vincentt
Posts: 112
Joined: 01 September 2017, 17:25

Re: Can you use arguments with this.setClientState?

Post by vincentt » 04 December 2019, 12:47

Hi,

When you do a client state, you do not go back to the server, you stays in the JS. The args parameters is necessary as you enter in a new state, managed by the JS framework. So this is used to initialize your state :)
I may be missing why you think you need to go back to the server for this..

Vincent

VanHlebar
Posts: 26
Joined: 24 September 2019, 02:30

Re: Can you use arguments with this.setClientState?

Post by VanHlebar » 05 December 2019, 03:33

hersh wrote:
03 December 2019, 05:42
try using the parameter named "args"

Code: Select all

this.setClientState("client_PlayerPlaceCaballeros", {
 	descriptionmyturn : _("${you} may place ${cabs_to_move} caballeros on the board."), 
        args: this.clientStateArgs        <------- make sure this object has "cabs_to_move" property defined
});
Ok not sure how I completely over looked your response earlier! This is what I was looking for and somehow just missed it completely. Thanks so much for the help to all of you! I promise to read better. :D

Post Reply

Return to “Developers”