Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-10-2011, 04:17 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
GS2 Beautifier

Disclaimer

If you already style your own code as you write it then you don't really need this unless you frequently find yourself styling other people's code. I.e: Forum helpers such as myself.

The Problem

If your code looks like this when you post it:

PHP Code:
//#CLIENTSIDE
function onCreated() {
if(
etc){
dostuff();
}
else
{
youneedthis();
}

You need to beautify/style your code before anyone else will be able to understand and read it properly. Readable code makes it much easier for others who want to help you.

After running it through the beautifier you're left with this:

PHP Code:
//#CLIENTSIDE

function onCreated() {
  if (
etc) {
    
dostuff();
  } else {
    
youneedthis();
  }

As you learn how to script and program, you'll also get into the habit of indenting and styling your own code as you write but until then you can just use the GS2 Beautifier before posting/sharing your code.

The Quick Fix

After witnessing an issue caused by the jsbeautifier.org and actual GS2 code I have forked the project, and modified it to properly support the following:

- public functions
- //#CLIENTSIDE
- Concatenation Symbols: @=, @, SPC, NL, TAB

I've also changed the default settings on the site to the style most experienced scripters use:

- Indent with two spaces
- Braces with control statements

PHP Code:
//#CLIENTSIDE
function onCreated() {
  echo(
"This is how it styles it...");

Instructions

1. Go to http://fp4.ca/gs2beautifier
2. Paste your code into the box
3. Click 'Beautify GS2'
__________________
Quote:

Last edited by fowlplay4; 08-10-2011 at 07:19 AM..
Reply With Quote
  #2  
Old 08-10-2011, 04:21 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Highlight shows #CLIENTSIDE has a space after it in the beautified code block. Does this generate that? If so you might want to fix that because I'm pretty sure that breaks scripts.
Reply With Quote
  #3  
Old 08-10-2011, 04:23 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Great!
Reply With Quote
  #4  
Old 08-10-2011, 04:25 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by DustyPorViva View Post
Highlight shows #CLIENTSIDE has a space after it in the beautified code block. Does this generate that? If so you might want to fix that because I'm pretty sure that breaks scripts.
Good catch, fixed.
__________________
Quote:
Reply With Quote
  #5  
Old 08-10-2011, 06:45 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
PHP Code:
(@something
becomes
PHP Code:
( @ something
which just looks... odd.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #6  
Old 08-10-2011, 06:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Tolnaftate2004 View Post
which just looks... odd.
I agree, fixed.
__________________
Quote:
Reply With Quote
  #7  
Old 08-10-2011, 10:45 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
+ rep. Very nice and very handy. Thank you!
__________________
Reply With Quote
  #8  
Old 08-10-2011, 10:58 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Gotta spread some rep first. Nice work.
__________________
Reply With Quote
  #9  
Old 08-13-2011, 11:29 PM
Rave_J Rave_J is offline
Graal Developer
Join Date: Feb 2006
Location: Texas
Posts: 848
Rave_J can only hope to improve
Send a message via AIM to Rave_J Send a message via MSN to Rave_J Send a message via Yahoo to Rave_J
easier way is
just copy the script open level editor
and put it in a npc and hit the style button and it will put it neatly


also i notice
level editor since v6 thing stefan updated
level editor will read most of gs2 from a npc
just dnt make it server side to use
but it will read it clientside just fine
__________________
Graal Developer
Reply With Quote
  #10  
Old 08-13-2011, 11:36 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
looking good (:

have to spread the love before i can give you some..

edit; just noticed that your triggerclient is missing the "gui" parameter
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #11  
Old 08-13-2011, 11:40 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Rave_J View Post
easier way is
just copy the script open level editor
and put it in a npc and hit the style button and it will put it neatly
No it isn't, and all that does indent your code.

GS2 Beautifier way: Open browser, go to website, paste code, click button.
Level Editor way: Open level editor, drag npc on to level, open npc script window, paste code, click button.

If you even looked at the example you would see that it does so much more than the level editor does.

Quote:
Originally Posted by Deas_Voice View Post
edit; just noticed that your triggerclient is missing the "gui" parameter
It isn't a strict requirement to put "weapon" or "gui" you can just put the weapon's name and it will still work.
__________________
Quote:
Reply With Quote
  #12  
Old 08-13-2011, 11:47 PM
Rave_J Rave_J is offline
Graal Developer
Join Date: Feb 2006
Location: Texas
Posts: 848
Rave_J can only hope to improve
Send a message via AIM to Rave_J Send a message via MSN to Rave_J Send a message via Yahoo to Rave_J
i never say that it didnt do more
i was stating there was a easier way maybe some people prefer to do just to set the style of ur code nicer. and i was saying u can gs2 script in level editor to a point just nothing on server side which is guis,systems ect like that just basic scripting for the levels to at least people can get the feel of it and somewhat use to it

but ur gs2 beautifier is nice dont get me wrong would be cool if u can add where it tells u errors
and suggestions on how to fix
__________________
Graal Developer
Reply With Quote
  #13  
Old 08-14-2011, 12:04 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Rave_J View Post
i never say that it didnt do more
i was stating there was a easier way maybe some people prefer to do just to set the style of ur code nicer. and i was saying u can gs2 script in level editor to a point just nothing on server side which is guis,systems ect like that just basic scripting for the levels to at least people can get the feel of it and somewhat use to it

but ur gs2 beautifier is nice dont get me wrong would be cool if u can add where it tells u errors
and suggestions on how to fix
I suggest you get the **** out of subforums you do not belong in.
__________________
Reply With Quote
  #14  
Old 08-14-2011, 12:05 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Rave_J View Post
but ur gs2 beautifier is nice dont get me wrong would be cool if u can add where it tells u errors
and suggestions on how to fix
The purpose is to style the code properly so other scripters such as myself can actually read your (and others) code, diagnose errors and suggest solutions to problems.

It is in no way meant to actually compile and run code. The level editor doesn't even do that properly with GS2.

It can't even do one of the most basic GS2 scripts:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  echo(
"Hello world!");

Level Editor Error: Unknown command: echo("Hello world!")
__________________
Quote:
Reply With Quote
  #15  
Old 08-14-2011, 12:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Crow View Post
I suggest you get the **** out of subforums you do not belong in.
+1

If you have questions or advice, you're always welcome, but we don't need useless, misinformed spam in these forums.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.