Poll

Is this a good idea?

You bet - the applications are endless!
16 (66.7%)
I guess so, but I doubt I'd get much use out of it
7 (29.2%)
Forget it - waste of time
1 (4.2%)

Total Members Voted: 24

Voting closed: August 02, 2003, 06:56:05 am

Author Topic: WIP - .TBL PHP Parser?  (Read 8186 times)

0 Members and 1 Guest are viewing this topic.

Offline Sandwich

  • Got Screen?
  • 213
    • Skype
    • Steam
    • Twitter
    • Brainzipper
WIP - .TBL PHP Parser?
I'm pondering coding up a PHP parser for FS1/2 tables, partially because I'd like to get some experience in parsing text files with PHP, and partially because it might be useful somehow.

Now, first of all, vote whether you think this could end up being useful... the possible applications are quite varied, everything from storing the .tbl info in a real database and outputting parts as needed, to comparing ship stats, to easy adjustment of various ship stats, built-in help for each option, etc etc etc.

Secondly, assuming the majority think this is worthwhile, I'll need some help, primarily in gathering up lists of all possible ship flags, attributes, context help explanations for the options, etc.

Thirdly, again assuming I go ahead with this, is there anyone of you who has past experience with PHP parsing of text files that I can work with? :D
SERIOUSLY...! | {The Sandvich Bar} - Rhino-FS2 Tutorial | CapShip Turret Upgrade | The Complete FS2 Ship List | System Background Package

"...The quintessential quality of our age is that of dreams coming true. Just think of it. For centuries we have dreamt of flying; recently we made that come true: we have always hankered for speed; now we have speeds greater than we can stand: we wanted to speak to far parts of the Earth; we can: we wanted to explore the sea bottom; we have: and so  on, and so on: and, too, we wanted the power to smash our enemies utterly; we have it. If we had truly wanted peace, we should have had that as well. But true peace has never been one of the genuine dreams - we have got little further than preaching against war in order to appease our consciences. The truly wishful dreams, the many-minded dreams are now irresistible - they become facts." - 'The Outward Urge' by John Wyndham

"The very essence of tolerance rests on the fact that we have to be intolerant of intolerance. Stretching right back to Kant, through the Frankfurt School and up to today, liberalism means that we can do anything we like as long as we don't hurt others. This means that if we are tolerant of others' intolerance - especially when that intolerance is a call for genocide - then all we are doing is allowing that intolerance to flourish, and allowing the violence that will spring from that intolerance to continue unabated." - Bren Carlill

 

Offline an0n

  • Banned again
  • 211
  • Emo Hunter
    • http://nodewar.penguinbomb.com/forum
Go find DM. He has skillz.
"I.....don't.....CARE!!!!!" ---- an0n
"an0n's right. He's crazy, an asshole, not to be trusted, rarely to be taken seriously, and never to be allowed near your mother. But, he's got a knack for being right. In the worst possible way he can find." ---- Yuppygoat
~-=~!@!~=-~ : Nodewar.com

 

Offline Sandwich

  • Got Screen?
  • 213
    • Skype
    • Steam
    • Twitter
    • Brainzipper
DM?
SERIOUSLY...! | {The Sandvich Bar} - Rhino-FS2 Tutorial | CapShip Turret Upgrade | The Complete FS2 Ship List | System Background Package

"...The quintessential quality of our age is that of dreams coming true. Just think of it. For centuries we have dreamt of flying; recently we made that come true: we have always hankered for speed; now we have speeds greater than we can stand: we wanted to speak to far parts of the Earth; we can: we wanted to explore the sea bottom; we have: and so  on, and so on: and, too, we wanted the power to smash our enemies utterly; we have it. If we had truly wanted peace, we should have had that as well. But true peace has never been one of the genuine dreams - we have got little further than preaching against war in order to appease our consciences. The truly wishful dreams, the many-minded dreams are now irresistible - they become facts." - 'The Outward Urge' by John Wyndham

"The very essence of tolerance rests on the fact that we have to be intolerant of intolerance. Stretching right back to Kant, through the Frankfurt School and up to today, liberalism means that we can do anything we like as long as we don't hurt others. This means that if we are tolerant of others' intolerance - especially when that intolerance is a call for genocide - then all we are doing is allowing that intolerance to flourish, and allowing the violence that will spring from that intolerance to continue unabated." - Bren Carlill

 

Offline an0n

  • Banned again
  • 211
  • Emo Hunter
    • http://nodewar.penguinbomb.com/forum
http://ironmarch.krabbit.com

Deadman.

He usually lurks on IRC.
"I.....don't.....CARE!!!!!" ---- an0n
"an0n's right. He's crazy, an asshole, not to be trusted, rarely to be taken seriously, and never to be allowed near your mother. But, he's got a knack for being right. In the worst possible way he can find." ---- Yuppygoat
~-=~!@!~=-~ : Nodewar.com

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
I think it would be good for newer modders, but not as useful for veterans.
-C

  

Offline phreak

  • Gun Phreak
  • 211
  • -1
it would be good to check if any errors exist in table entries before you test it in fs2 and it doesn't work
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline Sandwich

  • Got Screen?
  • 213
    • Skype
    • Steam
    • Twitter
    • Brainzipper
Ok, I've got initial parsing completed. The script will put a border around the main sections and a grey BG behind the section title and footer (eg. "#Ship Classes" and "#End"). It will display any comments in grey colored test, and will bold the attribute names (eg. $Name: GTF Ulysses).

It also displays a list of links to the different sections in the .tbl up top.

Check it out here, but keep in mind that it's big - upwards of 375Kb (which is the size of the ships.tbl). Note: the comments' color formatting seems to be messed up in Mozilla/Netscape.

Source:
  $table = file("ships.tbl");
$text = '
';
while (list (, $line) = each ($table)) {
$line = trim($line);

// BEGIN section check
if (strpos($line, "#") === 0) { // line begins with '#'?
if ($line == "#End") {
$line = '' . $line . "
";
} else {
$tbl_heading1_id++;
$index .= '' . $line . '
';
$line = '***** CLASS="tbl_heading1_text">' . $line . "";
}
// END check for section

// BEGIN check for comments
} elseif (strpos($line, ";") === 0) { // line is commented
if (strchr($line,":")) {
list($entry_type,$entry_value) = explode(":",$line);
$entry_type = trim($entry_type);
$entry_value = trim($entry_value);
$line = "$entry_type: $entry_value";
} else {
$line = "$line";
}
// END check for comments

// BEGIN data parsing
} elseif (!strlen($line) == 0) { // not blank line
list($entry_type,$entry_value) = explode(":",$line);
$entry_type = trim($entry_type);
$entry_value = trim($entry_value);
if (strchr($entry_value,";") === FALSE) {
// no comment found
} else {
list($entry_value_data,$entry_value_comment) = explode(";;",$entry_value);
$entry_value_data = trim($entry_value_data);
$entry_value_comment = trim($entry_value_comment);
$entry_value = "$entry_value_data\t\t\t;; $entry_value_comment";
}
$line = "$entry_type: $entry_value";
//if ($entry_type == "$Name") {
//$entry_list
//}
// END data parsing

} else {
// blank line
}

   $text .= $line . "\n";
}
$text .= "\n\n";
echo $index;
echo $text;
?>
 

Coming next:
- Color coding more sections
- Linking every occurance of any name attribute ($Name: XXXXX) text to that entry (for example, it would link the "Hornet" in every ship's allowable SBanks to the Hornet entry in the weapons.tbl)
- storage of every attribute and value pair in a database.

Comments and code streamline suggestions welcome. :nod:
SERIOUSLY...! | {The Sandvich Bar} - Rhino-FS2 Tutorial | CapShip Turret Upgrade | The Complete FS2 Ship List | System Background Package

"...The quintessential quality of our age is that of dreams coming true. Just think of it. For centuries we have dreamt of flying; recently we made that come true: we have always hankered for speed; now we have speeds greater than we can stand: we wanted to speak to far parts of the Earth; we can: we wanted to explore the sea bottom; we have: and so  on, and so on: and, too, we wanted the power to smash our enemies utterly; we have it. If we had truly wanted peace, we should have had that as well. But true peace has never been one of the genuine dreams - we have got little further than preaching against war in order to appease our consciences. The truly wishful dreams, the many-minded dreams are now irresistible - they become facts." - 'The Outward Urge' by John Wyndham

"The very essence of tolerance rests on the fact that we have to be intolerant of intolerance. Stretching right back to Kant, through the Frankfurt School and up to today, liberalism means that we can do anything we like as long as we don't hurt others. This means that if we are tolerant of others' intolerance - especially when that intolerance is a call for genocide - then all we are doing is allowing that intolerance to flourish, and allowing the violence that will spring from that intolerance to continue unabated." - Bren Carlill

 

Offline Taristin

  • Snipes
  • 213
  • BlueScalie
    • Skelkwank Shipyards
Err.. now, what exactly does this do?
Freelance Modeler | Amateur Artist

 

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
You know, I suggested something like this about a year ago. I believe Narol castigated me for DAYS about how bad an idea this was because it might make things too easy. ;)


Its still a good idea, in my opinion. Good job, Sandwich.
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline an0n

  • Banned again
  • 211
  • Emo Hunter
    • http://nodewar.penguinbomb.com/forum
What's $index?

EDIT: Nevermind, found it.
« Last Edit: August 02, 2003, 07:17:30 pm by 397 »
"I.....don't.....CARE!!!!!" ---- an0n
"an0n's right. He's crazy, an asshole, not to be trusted, rarely to be taken seriously, and never to be allowed near your mother. But, he's got a knack for being right. In the worst possible way he can find." ---- Yuppygoat
~-=~!@!~=-~ : Nodewar.com

 

Offline diamondgeezer

Aside from wanting to work with PHP for your own 'enjoyment', what's wrong with Wordpad? Table editing (and FREDding :nervous: ) the way our fathers did it.

 

Offline an0n

  • Banned again
  • 211
  • Emo Hunter
    • http://nodewar.penguinbomb.com/forum
The peoples need for progress must be satisifed.

Now either leave or be put to work in the cotton fields.
"I.....don't.....CARE!!!!!" ---- an0n
"an0n's right. He's crazy, an asshole, not to be trusted, rarely to be taken seriously, and never to be allowed near your mother. But, he's got a knack for being right. In the worst possible way he can find." ---- Yuppygoat
~-=~!@!~=-~ : Nodewar.com

 

Offline diamondgeezer

Well, it beats mining for coal I suppose

 

Offline Sandwich

  • Got Screen?
  • 213
    • Skype
    • Steam
    • Twitter
    • Brainzipper
Quote
Originally posted by an0n
What's $index?

EDIT: Nevermind, found it.


Hehehe - and I plan on further enhancing that llittle variable to be a expanding javascript menu system, allowing one-click access to any ship. :D

Quote
Originally posted by diamondgeezer
Aside from wanting to work with PHP for your own 'enjoyment', what's wrong with Wordpad?


Nothing, except for the same difference that there is between coding HTML in Notepad, and coding it in something that color-codes it. :)

Quote
Originally posted by diamondgeezer
...(and FREDding :nervous: ) the way our fathers did it.


You're insane. ;)
SERIOUSLY...! | {The Sandvich Bar} - Rhino-FS2 Tutorial | CapShip Turret Upgrade | The Complete FS2 Ship List | System Background Package

"...The quintessential quality of our age is that of dreams coming true. Just think of it. For centuries we have dreamt of flying; recently we made that come true: we have always hankered for speed; now we have speeds greater than we can stand: we wanted to speak to far parts of the Earth; we can: we wanted to explore the sea bottom; we have: and so  on, and so on: and, too, we wanted the power to smash our enemies utterly; we have it. If we had truly wanted peace, we should have had that as well. But true peace has never been one of the genuine dreams - we have got little further than preaching against war in order to appease our consciences. The truly wishful dreams, the many-minded dreams are now irresistible - they become facts." - 'The Outward Urge' by John Wyndham

"The very essence of tolerance rests on the fact that we have to be intolerant of intolerance. Stretching right back to Kant, through the Frankfurt School and up to today, liberalism means that we can do anything we like as long as we don't hurt others. This means that if we are tolerant of others' intolerance - especially when that intolerance is a call for genocide - then all we are doing is allowing that intolerance to flourish, and allowing the violence that will spring from that intolerance to continue unabated." - Bren Carlill

 

Offline J.F.K.

  • 29
I'm still a bit mystified as to what this 'Parser' actually does... mind putting it in plain terms for an idiot like me? :D
.
[font="SerpentineDBol"]. . . . W H O . I S . T H E . M A N , . W H O . I S . T H E . M Y T H ?[/font]

 

Offline Sandwich

  • Got Screen?
  • 213
    • Skype
    • Steam
    • Twitter
    • Brainzipper
It parses. :p

It'll turn this:

[q]$Name: GTF Ulysses[/q]

Into this:

[q]$Name: GTF Ulysses[/q]

Throughout the whole .tbl file, automagically!
SERIOUSLY...! | {The Sandvich Bar} - Rhino-FS2 Tutorial | CapShip Turret Upgrade | The Complete FS2 Ship List | System Background Package

"...The quintessential quality of our age is that of dreams coming true. Just think of it. For centuries we have dreamt of flying; recently we made that come true: we have always hankered for speed; now we have speeds greater than we can stand: we wanted to speak to far parts of the Earth; we can: we wanted to explore the sea bottom; we have: and so  on, and so on: and, too, we wanted the power to smash our enemies utterly; we have it. If we had truly wanted peace, we should have had that as well. But true peace has never been one of the genuine dreams - we have got little further than preaching against war in order to appease our consciences. The truly wishful dreams, the many-minded dreams are now irresistible - they become facts." - 'The Outward Urge' by John Wyndham

"The very essence of tolerance rests on the fact that we have to be intolerant of intolerance. Stretching right back to Kant, through the Frankfurt School and up to today, liberalism means that we can do anything we like as long as we don't hurt others. This means that if we are tolerant of others' intolerance - especially when that intolerance is a call for genocide - then all we are doing is allowing that intolerance to flourish, and allowing the violence that will spring from that intolerance to continue unabated." - Bren Carlill

 

Offline J.F.K.

  • 29
... :confused:

Okay, I'm still confused. Do you mean, then, that it changes the formatting (to blue, bold type in this case) of certain strings in the file? But aren't TBL files opened in Wordpad, where such formatting is irrelevant..? :o
.
[font="SerpentineDBol"]. . . . W H O . I S . T H E . M A N , . W H O . I S . T H E . M Y T H ?[/font]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
He means when it's displayed in the parser, it'll be colored like above. The file will still work normally.
-C

 

Offline Exarch

  • 27
Color coding basically helps skim a file faster, so besides all the nifty functions that'll probably be added later, even that is a considerable help :)

 

Offline Taristin

  • Snipes
  • 213
  • BlueScalie
    • Skelkwank Shipyards
What nifty functions?
Freelance Modeler | Amateur Artist