Page 1 of 1
How to update this.gamedatas in JS?
Posted: 02 March 2021, 04:01
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?
Re: How to update this.gamedatas in JS?
Posted: 02 March 2021, 07:20
by Tisaac
What are you trying to achieve ?
Re: How to update this.gamedatas in JS?
Posted: 02 March 2021, 11:18
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.
Re: How to update this.gamedatas in JS?
Posted: 02 March 2021, 12:06
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.
Re: How to update this.gamedatas in JS?
Posted: 02 March 2021, 15:35
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.
Re: How to update this.gamedatas in JS?
Posted: 02 March 2021, 18:51
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.
Re: How to update this.gamedatas in JS?
Posted: 03 March 2021, 22:50
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).