Jump to content

- - - - -

Script Example - Plus first results from parser



5 replies to this topic

#1 Dom

Dom

    I touch everything

  • UberGames Admin
  • 921 posts

Posted 17 September 2006 - 05:47 PM

Here is the first script (I have put the line numbers infront of the line);

01) //Script to open weapons locker door
02) if ((client[class] == class_admin) OR (client[class] == class_marine) OR (client[class] == class_security)) then
03) /*openDoor "doorTargetName"
04) adminMsg client[name]." is in the weapons locker"*/
05) console "useEnt doorTargetName"
06) else
07) adminMsg "Client ".client[number]." tried to access the admin door"
08) playSound "denied.mp3
09) console "msg This is the server and it is coming to eat you alive and all this message is going to be too long for the line buffer, oh no what ever should I do asked the person writing the script, but he never got an answer from the complier it just said that the line was too long to be pharsed."
10) end if

And this is what the parser spitted out to the console;

Loading Script 'testScript.xsc'

-------------------------------------
Beinging First Pass of XSC File
-------------------------------------
X-Script Warning: Line 8 has a non closed quote.
X-Script Warning: Line 9 is bigger than the buffer (256 characters).

And this is what the parser had left after the first pass;

if ((client[class] == class_admin) OR (client[class] == class_marine) OR (client[class] == class_security)) then
console "useEnt doorTargetName"
else
adminMsg "Client ".client[number]." tried to access the admin door"
end if

As you can see all the first pass did was remove all the comments and whitespace, detect an error on line 8, tell you it could not read line 9 as that is too bloody long and clean up the whitespace on the line themselves.

What I have posted as the script is an example of what I believe the scripts will end up looking like.
Dom 'Phenix'
UberGames Developer

Ennoverse Web Hosting
http://www.ennoverse.com
http://www.ennoverse.co.uk
Affordable web hosting and domains.

A Division of UberNet Ltd.

#2 William

William

    Lead Level Developer - RPG-X

  • UberGames Developer
  • 728 posts

Posted 17 September 2006 - 06:09 PM

If i had any idea what phaser was or what specifically .XSC is, I might be able to comment further.

On the face of it, (besides the fact your displaying it in a php window) it looks very similar to PHP, that would make it easy to adapt to at least :)

I also notice, that rather than having functions for calling each entity, you use a console command... I know for a fact its virtually impossible to find the entity numbers of target_relays etc, I'd hope we'd be able to use entitys via their targetname too...

#3 RedTechie

RedTechie

    UberGames Administrator

  • UberGames Admin
  • 276 posts

Posted 17 September 2006 - 07:26 PM

phaser == parser.... for some reason phenix thinks thats the way you spell parser :S lol
RedTechie
UberGames Administrator


Need Affordable Game Servers or Web Hosting?

Ennoverse Ltd.
http://www.ennoverse.com
http://www.ennoverse.co.uk
Affordable Game Servers, Web Hosting, Domains, and SSL.

We also offer Elite Force and Elite Force 2 hosting!

#4 Scooter

Scooter

    The Canon Man

  • UberGames Admin
  • 2,545 posts

Posted 18 September 2006 - 10:06 PM

Actually the syntax is closer to Visual Basic than PHP. Was there some problem with curly brackets that made this necessary?

#5 Dom

Dom

    I touch everything

  • UberGames Admin
  • 921 posts

Posted 19 September 2006 - 08:12 AM

Was there some problem with curly brackets that made this necessary?


Technicaly no, however the parser goes line by line and most people (myself including like writing

if ($something)
{


The parser would had to have extra code to understand it being on multible lines, however the basic version is written on one line and for newbie programmers is problery easier to pick up.
Dom 'Phenix'
UberGames Developer

Ennoverse Web Hosting
http://www.ennoverse.com
http://www.ennoverse.co.uk
Affordable web hosting and domains.

A Division of UberNet Ltd.

#6 TiM

TiM

    Administrator

  • UberGames Admin
  • 3,425 posts

Posted 19 September 2006 - 04:31 PM

If you're using the core text parsing functions in EF, that's irrelevant.

To the parser:

if ( condition ) { events; }

is the same as

if ( condition ) {
events;
}

is the same as

if ( condition )
{
events;
}

unless you specifically specify otherwise in the parsing function's parameters.

It will only not pick up a brace in one of the parse cycles if you appended it to something. (so you have to be careful to put a space between '(condition)' and '{'. )

-TiM




Reply to this topic



  

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users