Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-27-2012, 06:47 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
GS2 Emulator

We're all aware of the issue regarding being unable to test GS2 without NC, and that GS2 is very similar to JavaScript. It's similar enough with a little bit of replacing that I could get a bunch of basic output scripts to run.

So in order to help newbies get into GS2 and complete the first few (5) parts and first challenge of my tutorial I have created a basic emulator.

This is currently just a learning tool to allow newbies to get their feet wet, anyone who wants to further develop it is welcome to. There's still plenty to do. I.e. Simulated Client-Side/Server-Side functionality (and triggerserver/triggerclient), proper temp prefix functionality, GS2 to JS array conversion, numerous global functions.

Notes:
  • Concatenation symbols (@, SPC, NL, TAB) are replaced with their javascript equivalent.
  • All variables are global so the temp prefix will not work the same way as it does in GS2.
  • Arrays and a vast majority of other functions are currently not emulated. If you want to use array's use [ and ] instead of { } when defining them.

Enjoy.

Link: http://fp4.ca/gs2emulator/
Tutorial: http://public.zodiacdev.com/index.php?title=Fowlplay4
__________________
Quote:

Last edited by fowlplay4; 02-27-2012 at 08:35 PM..
Reply With Quote
  #2  
Old 02-27-2012, 07:19 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I'm attempting to test it on my phone. This isn't working for me

function onCreated() {
temp.I =0;
Temp.t = { "Paul", "frank", "Sam"};
For(temp.I=0; temp.I<temp.t.size();temp.I++){
Echo(temp.t[temp.I]);
}
}
Reply With Quote
  #3  
Old 02-27-2012, 07:22 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Attempted using [ and ] for the array
Reply With Quote
  #4  
Old 02-27-2012, 07:26 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
This forest work either
function onCreated() {
Temp.t = [ "Paul", "frank", "Sam"];
For(temp.I : temp.t){
Echo(temp.I);
}
}
Reply With Quote
  #5  
Old 02-27-2012, 07:36 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
Anything array-based really doesn't work at all unless you know how arrays work in JS.

The temp is case-sensitive, and it's length not size() in JS. What does work is:

PHP Code:
function onCreated() {
  
temp.= ["Paul""frank""Sam"];
  for (
temp.I=0temp.temp.t.lengthtemp.I++){
    echo(
temp.t[temp.I]);
  }

The only GS2 function that is currently implemented is echo().

Keep in mind this emulator is still very much a work-in-progress.
__________________
Quote:
Reply With Quote
  #6  
Old 02-27-2012, 07:39 PM
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
JavaScript uses for (member in object) { ... } which is like for (member: object.getvarnames()) { ... }. That's probably why it's not working.

e: Good lord is this a horror.

e2: Array.prototype.size = function () { return this.length; }. Do it.
__________________
◕‿‿◕ · 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
  #7  
Old 02-27-2012, 08:02 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
Cleaned up the source code a little bit, added size since it was right there.

gs2_setup() - Implements some GS2-like functionality.
gs2_script() - Does some small conversions.
gs2_emulate() - Calls setup, clears output, gets script, and evals it as JS.

So if you want to add to it go for it.

This also works now but I would suggest not trying to script on your phone.

PHP Code:
function onCreated() {
  
temp.=0;
  
temp.= ["Paul""frank""Sam"];
  for (
temp.I=0temp.temp.t.size(); temp.I++){
    echo(
temp.t[temp.I]);
  }

__________________
Quote:
Reply With Quote
  #8  
Old 02-27-2012, 08:21 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I was just testing it on my phone. I wouldn't normally use uppercase letters when defining a variable it was just the auto correct on my phone. If I had known it would make a difference I would have changed it.this thing is still pretty nifty
Reply With Quote
  #9  
Old 02-27-2012, 09:13 PM
smirt362 smirt362 is offline
Tee Hee
smirt362's Avatar
Join Date: Feb 2005
Location: Texas
Posts: 2,101
smirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant futuresmirt362 has a brilliant future
Send a message via AIM to smirt362 Send a message via MSN to smirt362
Neato!
__________________

Don Hertzfeldt <3
Reply With Quote
  #10  
Old 02-27-2012, 09:16 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quite the hack, but I guess it's better than nothing.
Reply With Quote
  #11  
Old 02-27-2012, 09:35 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
oh graal players, always doing the dirty work "they" should have done ages ago
__________________
Reply With Quote
  #12  
Old 02-27-2012, 09:59 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
I spose you're still yet to implement for each loops?
Reply With Quote
  #13  
Old 02-27-2012, 10:09 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 Tricxta View Post
implemented for each loops?
They are not, need arrays properly converted before that will happen.
__________________
Quote:
Reply With Quote
  #14  
Old 02-27-2012, 10:24 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
I really wish you never did this. It's never going to get anywhere because it's a weird Javascript parser and preprocessor step rather than an actual VM or even interpreter, yet people in the future will point back to it and go, "Look, it exists! Now shut up." There are so many reasons why this is a bad idea.
Reply With Quote
  #15  
Old 02-27-2012, 10:27 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Quote:
Originally Posted by Hezzy002 View Post
I really wish you never did this. It's never going to get anywhere because it's a weird Javascript parser and preprocessor step rather than an actual VM or even interpreter, yet people in the future will point back to it and go, "Look, it exists! Now shut up." There are so many reasons why this is a bad idea.
Sure is better than nothing for newbies who want to learn.
__________________
Reply With Quote
  #16  
Old 02-27-2012, 11:08 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 Hezzy002 View Post
I really wish you never did this. It's never going to get anywhere because it's a weird Javascript parser and preprocessor step rather than an actual VM or even interpreter, yet people in the future will point back to it and go, "Look, it exists! Now shut up." There are so many reasons why this is a bad idea.
I get that this isn't the 'traditional way' to do things, and is just a hack that takes advantages of the similarity between the two languages.

I barely have any experience writing a VM or interpreter (or really anything that low-level), I'm just trying to provide something usable for the masses who actually want to write something that would work in an actual GS2 script, and perhaps maybe make them feel like they have a chance if they do decide to get a gold account and NC Access.

If you focus entirely on the 'bad' and give yourself reasons why it shouldn't be done, ignore any positive benefits then nothing will get done.
__________________
Quote:
Reply With Quote
  #17  
Old 02-28-2012, 03:33 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
I get that this isn't the 'traditional way' to do things, and is just a hack that takes advantages of the similarity between the two languages.

I barely have any experience writing a VM or interpreter (or really anything that low-level), I'm just trying to provide something usable for the masses who actually want to write something that would work in an actual GS2 script, and perhaps maybe make them feel like they have a chance if they do decide to get a gold account and NC Access.

If you focus entirely on the 'bad' and give yourself reasons why it shouldn't be done, ignore any positive benefits then nothing will get done.
I'd agree if it were any other community, but that's been Graal's mantra for the last decade. Hell, you could've picked apart an open source Javascript engine and added these things to the core, not as a preprocessor step, and I'd have been very, very happy with that.
Reply With Quote
  #18  
Old 02-28-2012, 03:46 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
Do you intend this to be a syntax checker? If so then this is good. For example I have no access to GS2 at the moment but sometimes I am asked to convert simple things. To be able to make sure I made no mistakes would be nice. But as for learning I can't say this would be useful past the very very basics of scripting, can you? Most people are interested in developing in Graal because OMG GRAPHICS and this won't be able to provide that sort of satisfaction. The most it would be able to do in its fullest potential are simple echos and evaluations.

Not trying to downplay what you're doing, it's great that people like you try to provide services that devs should get but don't, but I'm wondering if it will be worth the effort in the end.
Reply With Quote
  #19  
Old 02-28-2012, 05:47 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 Hezzy002 View Post
I'd agree if it were any other community, but that's been Graal's mantra for the last decade. Hell, you could've picked apart an open source Javascript engine and added these things to the core, not as a preprocessor step, and I'd have been very, very happy with that.
I'll consider it but that would probably just get to the point where I would have to basically code my own 'Graal' client just to be able to provide a decent full-fledged GS2 emulation experience.

Quote:
Originally Posted by DustyPorViva View Post
Not trying to downplay what you're doing, it's great that people like you try to provide services that devs should get but don't, but I'm wondering if it will be worth the effort in the end.
But for something that I really only put maybe an hour and a half into it's definitely worth it for those starting out.

There's nothing more de-motivating to newbies than reading my tutorial only to find that out that the only way you can complete the first part is plopping cash down for a gold account and managing to find NC access.

Also hoping that maybe Stefan will take interest in this kind of project, and just maybe he'll consider making development more accessible.
__________________
Quote:
Reply With Quote
  #20  
Old 02-28-2012, 05:56 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
Quote:
Originally Posted by fowlplay4 View Post
There's nothing more de-motivating to newbies than reading my tutorial only to find that out that the only way you can complete the first part is plopping cash down for a gold account and managing to find NC access.
But what about when they get to the second part, the more interesting making game-stuff/graphical part of the tutorials where they will still have to plop down cash to do it?

Like I said kudos to you for doing this but I'm just wondering if the benefits make the effort worth it. But then again sometimes I do a lot of stuff with absolutely no benefit and lots of effort.

I guess in the end you can make a syntax checker out of it?
Reply With Quote
  #21  
Old 02-28-2012, 06:24 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
But what about when they get to the second part, the more interesting making game-stuff/graphical part of the tutorials where they will still have to plop down cash to do it?

Like I said kudos to you for doing this but I'm just wondering if the benefits make the effort worth it. But then again sometimes I do a lot of stuff with absolutely no benefit and lots of effort.

I guess in the end you can make a syntax checker out of it?
Well, I'm hoping it'll get them in the door and make them want more. I'll have to wait for feedback from new scripters who used it when they were learning to see whether it was effective or not. I know one person who wanted to learn GS2 was really happy about it so far.

I might attempt to, might be able to apply my learnings from that and end up with in-game GS2 Emulator (GS2ception) which would allow them to actually use the engine. Might require gold depending on where they can use it but it would remove the NC requirement.

We'll just have to see what I do next.

Quote:
Originally Posted by Hezzy002 View Post
An HTML5 Graal clone would be interesting.
Sounds like a pending C&D to me.
__________________
Quote:
Reply With Quote
  #22  
Old 02-28-2012, 06:35 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
Sounds like a pending C&D to me.
I started working on a multiuser HTML5 Graal chatroom thing, it could load NW and gani files by requesting them through AJAX request and used websockets for actually sending player positions and chat and stuff. I dunno why, I just had 45 minutes every day, for a few weeks, without admin rights and with only a browser and notepad in front of me.

Maybe I'll use the gani stuff for an online gani editor, that'd be useful.
Reply With Quote
  #23  
Old 02-29-2012, 07:29 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
Updated to V1.1

1. Support for GS2 Arrays
2. GS2's for each loop is now supported as well.

Many thanks to Jazz for that.

Link: http://fp4.ca/gs2emulator/
__________________
Quote:
Reply With Quote
  #24  
Old 02-29-2012, 07:15 PM
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
Quote:
Originally Posted by fowlplay4 View Post
1. Support for GS2 Arrays
Hate to burst your bubble but you're not going to find a way to replace GS-style arrays with a regex.

First thing I tried of course was
a = {1,2,{3,4}};
which broke it.

There's gonna need a lot more work put into this to get proper GS emulation in JS. At a minimum, you'll likely need to break the GS into an AST and have a visitor reconstruct into JS.

As far as GSception goes, there were 2 things written a few years back:
by me
by zero (ziro?) / zokemon
__________________
◕‿‿◕ · 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 :/

Last edited by Tolnaftate2004; 02-29-2012 at 07:41 PM..
Reply With Quote
  #25  
Old 02-29-2012, 08:06 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
Added another hack to get that working, and noted the limitation.

And yes, I understand how much work a proper emulation would take and that using regex is just a hack solution.
__________________
Quote:
Reply With Quote
  #26  
Old 03-05-2012, 11:21 PM
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
Quote:
Originally Posted by DustyPorViva View Post
Do you intend this to be a syntax checker?
Here ya go.

e: Just check my sig. I keep updating this post, and eventually I won't be able to anymore.
__________________
◕‿‿◕ · 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 :/

Last edited by Tolnaftate2004; 03-06-2012 at 10:26 PM..
Reply With Quote
Reply


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 08:08 PM.


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