Page 1 of 1
Slight Confusion on Tutorial.
Posted: 10 January 2014, 01:28
by Deluxe Flame
I am following along with the reversi tutorial. I've reached the part where it says
"Now, to test if everything works fine, just call "this.addTokenOnBoard( 2, 2, <your_player_id> )" in your "setup" Javascript method, and reload the page. A token should appear and slide immediately to its position, like this: "
I don't know what I put for <your_player_id>
I understand that to use addTokenOnBoard it pulls x, y, and player.
I don't know what player is.
Is it the actual name of the players?
is it some sort of array listing the players, i.e; player1, player2, etc.
I've tried searching all the files in my home folder for some initialization of players but didn't see anything.
I'm new to BGA dev, and have most experience with C# coding.
haha, to be frank, I don't even know what programming language I'm learning in this tutorial, is it html, java, javascript?
Re: Slight Confusion on Tutorial.
Posted: 10 January 2014, 03:21
by Deluxe Flame
I've gone into the SQL database.
it looks like the value for player_id is 2260488,
I've tried it in the code (2,2, 2260488) but no results =/
Re: Slight Confusion on Tutorial.
Posted: 10 January 2014, 09:54
by pikiou
The author of this tutorial confessed it was just meant to be read, so there may be errors preventing it from working.
I fixed about a dozen errors a year ago to make it work, but it may not have been enough.
I would strongly advise you to learn about the basics of HTML, CSS, Javascript (+dojo) and PHP in that order before you go further, otherwise you will spend months of frustrating debugging.
You should find lots of free tutorials on these subjects.
No need to learn SQL if you ask me for some tools interfacing it when you learnt about the rest.
Re: Slight Confusion on Tutorial.
Posted: 10 January 2014, 11:47
by sourisdudesert
Hi,
In fact the "player_id" is the player_id of the player who own the token. As it is one of your player the tutorial cannot knows it
Your approach is the good one: find the player_id in the database and use it.
Cheers,
Re: Slight Confusion on Tutorial.
Posted: 10 January 2014, 13:48
by Deluxe Flame
My biggest trouble with this is switching between different windows and codes.
Is there any sufficient program that I can use to program for BGA?
I see that notepad++ can identify and view certain files, but not all of them.
Re: Slight Confusion on Tutorial.
Posted: 15 July 2015, 13:47
by Coin-coin le Canapin
Hi,
I'm trying to follow this tutorial as well and I have an issue on this part :
addTokenOnBoard: function( x, y, player )
{
dojo.place( this.format_block( 'jstpl_token', {
x_y: x+'_'+y,
color: this.gamedatas.players[ player ].color
} ) , 'tokens' );
this.placeOnObject( 'token_'+x+'_'+y, 'overall_player_board_'+player );
this.slideToObject( 'token_'+x+'_'+y, 'square_'+x+'_'+y ).play();
},
I assume we have to put this between the <script> tags on the .tpl file, but javascript throws an error :
Any idea ?
Re: Slight Confusion on Tutorial.
Posted: 15 July 2015, 14:46
by Quinarbre
This function goes into your .js file (every Javascript function actually).
The .tpl is just here for templates, ie bits of html code that should be generated by your Javascript code but that you don't want to write verbatim into your code (as usual, with the intent of separating logic from look&feel).
Re: Slight Confusion on Tutorial.
Posted: 15 July 2015, 15:27
by Coin-coin le Canapin
Thank you

Re: Slight Confusion on Tutorial.
Posted: 18 July 2015, 18:56
by Coin-coin le Canapin
There are some differences between the tutorial code and the actual reversi code ; sometimes "token" is various places instead of "disc". I spend some time trying to figure out what was going on.
Re: Slight Confusion on Tutorial.
Posted: 19 July 2015, 00:32
by pikiou
Feel free to directly fix these errors on the wiki!
I mentioned above that there were errors and that the tutorial was meant to be read, not copy/pasted and ran.
Something else: the error you had in JavaScript above was really obvious so I'm guessing you're new to it. You should spend some time learning the language; you'll have way more fun coding and it'll save you 100+ hours of debugging just for your first project.
BGA Studio projects are run in an remove noob unfriendly proprietary environment so you will have to know what you're doing. It's the worst place to learn about a new language with a try and error approach.
I gave that warning multiple times, was ignored, and no project was finished from the persons I warned. Their projects raised a level of bad practice no one wanted to have to do anything with.