Page 1 of 1
how to?
Posted: Sat Jun 11, 2011 10:31 am
by bowersbros
Right, as you know (most of you)
Im building a game, and i ran into a little problem.
basically, ive started the game over 3 times, first it was to be done in PHP and Html.
didnt like it,
then it was flash and java (with Smartfoxserver)
That was too expensive. (£3500 per server just for smartfoxserver software! :/)
Now its most likely just java.
But, i need to know. how do i convert a php array into java?
I wrote a MASSIVE array, and it took me over 15 hours to code it (it was f**king tedious i tell you)
And i just hope to god there is an easy online conversion or anything and was hoping one of you guys can help me out?
Thanks so much
Note, ill upload the array soon for if anybodys interested?
Re: how to?
Posted: Sat Jun 11, 2011 10:34 am
by bowersbros
note: Thank god for backup drives.
I lost the original, and its over 4,000 lines long and not quite complete yet
Re: how to?
Posted: Sat Jun 11, 2011 10:38 am
by jacek
What does an array in java look like ? You could include the file with php and then use implode and write the result to a file.
Re: how to?
Posted: Sat Jun 11, 2011 10:42 am
by bowersbros
well the arrays (annoyingly) have to be a certain datatype (eg. int or char) not a mixture like my php one is.
Also, you need a known length (i cant physically count how many data types i have)
Re: how to?
Posted: Sat Jun 11, 2011 10:48 am
by jacek
bowersbros wrote:well the arrays (annoyingly) have to be a certain datatype (eg. int or char) not a mixture like my php one is.
php can work that out, is_int() is_bool() etc
bowersbros wrote:Also, you need a known length (i cant physically count how many data types i have)
php can also work that out.
and you still haven't said what they look like
Re: how to?
Posted: Sat Jun 11, 2011 10:54 am
by bowersbros
int[] cost = new int[15];
That creates an integer array named variable cost which is 15 fields long (goes up to cost[14])
same for any other type, eg.. double, char etc.
Re: how to?
Posted: Sat Jun 11, 2011 10:56 am
by jacek
Oh you cant have mixed type arrays ?
I guess you need to work out a way to split it up then.
Re: how to?
Posted: Sat Jun 11, 2011 11:11 am
by bowersbros
Oh joys.
I might either try to find a way to use php arrays with java, or just retype it all up again
Re: how to?
Posted: Sat Jun 11, 2011 11:18 am
by jacek
bowersbros wrote:use php arrays with java
no.
bowersbros wrote:just retype it all up again
not the best way.
When I said split it up, I mean is there some logical way the data types can be separated ? A php script can do that actual separating.
Re: how to?
Posted: Sat Jun 11, 2011 11:27 am
by bowersbros
but then I would have several different arrays, im not looking for that.
Ill post my current one so you can see what it is like:
/edit.
Change of plan.
Apparently my message went 48,171 characters over phpbb limit
Ill find a way to paste it, one minute
/edit:
http://pastebin.com/1jN78pua
Re: how to?
Posted: Sat Jun 11, 2011 11:29 am
by Tino
Use pastebin or something?
Re: how to?
Posted: Sat Jun 11, 2011 11:32 am
by bowersbros
Tino wrote:Use pastebin or something?
have done
Re: how to?
Posted: Sat Jun 11, 2011 11:56 am
by Tino
Java is an OO language, right? Isn't there some way to convert a PHP array to a Java object?
Re: how to?
Posted: Sat Jun 11, 2011 11:57 am
by bowersbros
thats what I was thinking, but i couldnt find anything on google.
Re: how to?
Posted: Sat Jun 11, 2011 1:58 pm
by jacek
bowersbros wrote:thats what I was thinking, but i couldnt find anything on google.
What does an object look like ?
You need to create the syntax with php and write it to a file.
Re: how to?
Posted: Sat Jun 11, 2011 2:01 pm
by bowersbros
What is the best way for a huge settings file? It will be called on almost every single page (if not all)
should i just make a huge database table so i only fetch what i ened insead of the entire file?
It will also allow multi datatypes
Re: how to?
Posted: Sat Jun 11, 2011 4:38 pm
by jacek
If the settings change a lot that would be a good way to make them easy to update.
Re: how to?
Posted: Sat Jun 11, 2011 5:47 pm
by bowersbros
jacek wrote:If the settings change a lot that would be a good way to make them easy to update.
Well.. they wont change alot. but they will change gradually
Any idea what fields i should have to set that up? or should i have 1 table for each type (buildings, troops, resource, capacity, etc.)
Re: how to?
Posted: Sat Jun 11, 2011 6:58 pm
by jacek
bowersbros wrote:Any idea what fields i should have to set that up? or should i have 1 table for each type (buildings, troops, resource, capacity, etc.)
It depends how the data will be used, you could do it like that, or have it all in one massive table.