How to update this.gamedatas in JS?

Game development with Board Game Arena Studio
Post Reply
User avatar
Ciffy
Posts: 30
Joined: 18 August 2015, 21:59

How to update this.gamedatas in JS?

Post by Ciffy »

There are several old threads and a sentence in the yourgame.js document that says you can update gamedatas as needed, but nowhere that actually says HOW to do it.

As this is my first game, I'm still trying to wrap my head around the framework, so I either need a way to update gamedatas, or a way to run a new SQL query and get the results back to the javascript. It would seem while I'm still getting used to things, that the "update gamedatas" route is the path of least resistance.

Can anyone point me in the right direction?
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: How to update this.gamedatas in JS?

Post by Tisaac »

What are you trying to achieve ?
User avatar
Ciffy
Posts: 30
Joined: 18 August 2015, 21:59

Re: How to update this.gamedatas in JS?

Post by Ciffy »

Tisaac wrote: 02 March 2021, 07:20 What are you trying to achieve ?
I need piece data (location, etc) of stuff thats been placed since the page loaded.

I have what I'm trying to achieve mostly working, but it requires a page refresh.
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: How to update this.gamedatas in JS?

Post by Tisaac »

Then it's notifications that you should look at.
But if you went through the tutorials, you probably should know how to use them.
User avatar
Ciffy
Posts: 30
Joined: 18 August 2015, 21:59

Re: How to update this.gamedatas in JS?

Post by Ciffy »

Is there just not a way to update gamedatas?

And I thought about going through notifications, but how do I get data back OUT of whatever I run in the notification (ie the piece data), beyond the notif.args?

The stuff I've read so far is just updating all players on a move that's just happened. There's nothing about using that data elsewhere. Do I just set up a global? That seems like it can't be right.
User avatar
Ciffy
Posts: 30
Joined: 18 August 2015, 21:59

Re: How to update this.gamedatas in JS?

Post by Ciffy »

So for what its worth, for better or worse, I did a this.gamedatas.piece.push() in the notif_playpiece function and sent an array identical to the output of the pieces sql statement during the php getalldatas method. Not sure if that's what you were implying I needed to do, but it seems to have fixed my needing to reload issue. Thx.
User avatar
Hornir91
Posts: 38
Joined: 15 October 2018, 06:39

Re: How to update this.gamedatas in JS?

Post by Hornir91 »

Yes, you can probably store some variables as global values with "this.variable = something" and call it whenever you want. Eventually if you need a piece of information for the whole gamestate (e.g. playerturn) you can load it through "args" which you need to define in your states.inc.php and gamename.game.php (as function to get values for args from DB).
Post Reply

Return to “Developers”