![]() |
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:
Enjoy. Link: http://fp4.ca/gs2emulator/ Tutorial: http://public.zodiacdev.com/index.php?title=Fowlplay4 |
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]); } } |
Attempted using [ and ] for the array
|
This forest work either
function onCreated() { Temp.t = [ "Paul", "frank", "Sam"]; For(temp.I : temp.t){ Echo(temp.I); } } |
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:
Keep in mind this emulator is still very much a work-in-progress. |
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. |
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:
|
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
|
Neato!
|
Quite the hack, but I guess it's better than nothing.
|
oh graal players, always doing the dirty work "they" should have done ages ago
|
I spose you're still yet to implement for each loops?
|
Quote:
|
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.
|
Quote:
|
Quote:
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:
|
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. |
Quote:
Quote:
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:
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? |
Quote:
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:
|
Quote:
Maybe I'll use the gani stuff for an online gani editor, that'd be useful. |
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:
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 |
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:
e: Just check my sig. I keep updating this post, and eventually I won't be able to anymore. |
All times are GMT +2. The time now is 06:28 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.