Can you edit an external map .txt file via php!?

  • dann_the_van
  • Novice
  • Novice
  • dann_the_van
  • Posts: 23
  • Loc: South Wales, UK

Post 3+ Months Ago

Hi people,
this is my first time on a forum for flash, so please be easy on any mistakes i make along the way. i've only got into flash within the past few months, and i'm honest to say i'm not highly experienced within the actionscript field.

-------------------------

I'm working on a 3rd year university project using flash mx 2004. I'm using a code, similar to TonyPA's, to attach square movieclips onto the stage and then play a certain frame of that MC using data collected via loadVars. For example:
The 4th plotted tile is dynamically named "SQ4". This then loads a variable from a file named "SQ4.txt".



Upon testing this when published upon the web, the map builds quickly but then takes a few minutes to load the relevant data variables and then play it's specific frame. I must mention though, there is currently over 200 tiles on the screen, which loads bottom to top.

So, i decided to alter the script to load what frame to play, straight from the map coding.
i'm now using something along these lines...

map = [ [1, 2, 3, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
];

the numbers represent what frame to play of each movieclip. 0 being empty, 1 being filled red, 2 blue, 3 yellow etc etc.

by using the #include handle, i have saved this map data inside an external file, and compile it into flash. Up to here i'm fine! not bad for someone who's used it for around 2-3 months!? :)

But here's the problem.. :(

is it possible to have a php script edit the external file's data... for example, if i clicked a movieclip playing 'red'(1), can i create a process, through php to change that value. Permanently!
Clicking the red clip allows me to enter a few details about something, then press an 'ok' button, over-writing the external file, to change the number '1'(red) into a '2'(blue)... but only that clicked '1'!

I've read examples where php is used to delete values from arrays... but i'm wanting to change the values. Dynamically via php.

but should something go wrong, i will ultimately need to be able to pin-point what value has been changed, so that i can change it back to it's previous state.

Can this be done using a table of data (xml?), and create a php script to change value via an x/y axis like that of a road map. for example, column g, row 5 (G/5) = "1".

Please please please help a student in need! any guidance would be appreciated and credited!

Thanks,
Danny
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

i made a map editor and i used asp to write the data ... php would be as easy.
The thing is that i save the whole data when user press Save button, and also i format the data my way, not like you did. TonyPA's is a great site with tutorials about making a tile game :D
I'm still in the mid of the game. If you want to take a look at both the game and map editor ... Game
Map Editor
  • David Raz
  • Banned
  • Banned
  • User avatar
  • Posts: 52
  • Loc: West coast

Post 3+ Months Ago

Nice game!
Hours of worthless fun :D
  • dann_the_van
  • Novice
  • Novice
  • dann_the_van
  • Posts: 23
  • Loc: South Wales, UK

Post 3+ Months Ago

Hi IceCold,

your map editor is a fine way of creating maps.. but it's not exactly what i'm looking towards.

i'm looking to produce a way of editting the original map.txt file, so that everyone else accessing the webpage could see the updated values on screen.
If for example you could imagine a plane of 100x100 tiles all red(using the number 1), and someone was to click the 34th tile, after hitting a 'process/ok/update' button on a php form, the original value of that 34th array(1) would change to a different number(2).

I've got a friend looking at it, who says he could use php+html variables to count the commas within the map file, and change the specific value that way. with luck, we'll accomplish it!

but if anyone has had any experience doing this or know of a different way.... please let me know.

Thanks, once again.
Dan
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

that's exactly what my map editor does ... only it lacks the save function for now since it's asp made and the host has only php support. If you looked at my map, you could see that i display info for each tile, once you pressed it, so i know exactly which tile is changed.

You could send the number of tile being changed to a php script which will search for that position and modify it, but to change only the value at that position would mean to open the file in binary mode, not as text, and count the number of commas.

If you open it as text, then you'll have to overwrite the whole map values.
Either way it can be done.
  • dann_the_van
  • Novice
  • Novice
  • dann_the_van
  • Posts: 23
  • Loc: South Wales, UK

Post 3+ Months Ago

Hi guys.

We're looking into counting the commas and changing information that way...

but please help me with my next problem...

the tiles are formed in a rough shape of the uk, and i'm wanting to overlay a graphic of the major uk roads but need help doing this! http://www.ozzu.com/ftopic74561.html

Thanks for the replies guys.
Danny
  • dann_the_van
  • Novice
  • Novice
  • dann_the_van
  • Posts: 23
  • Loc: South Wales, UK

Post 3+ Months Ago

Hi Icecold,

Umentioned earlier on this topic opening a text file as 'binary' and not a text file to change the value of a targeted element.
What is this techniques to open it as binary?
Would i still be able to save it to a file in text format!?

Thnx,
Danny

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.