123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|569|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> JSE -> JSE - Jay's Scripting Engine

Page : 1 2 Next 3 4 5 6 7 8 9 10 11 12 13 14
Prev
Sun, 21 Feb 2021, 09:11
Jayenkai

JSE - Jay's Scripting Engine


|update| JSE is now LIVE! |update|

JSE is now a mostly-functioning Scripting language. Code examples and smaller games using a BASIC/Blitz-like syntax, directly in your browser.
Head to GotoJSE.com, and get coding!

-=-=-

Very very very very very very basic stuff, here!!

Don't get overexcited, I might still completely screw this up!!

This is the input.


This is the output.


Things of note

1. Handles multiple spellings of the command to SetColour/Color/Col, and Rect/FillRect
2. Uses ; or : to separate commands, and happily ignores any that are left at the end of a line, ala Blitz
3. You can choose to use or not brackets as you go, again ala Blitz.
4. Graphics sets the virtual resolution, but currently everything is then scaled to "as big as will fit on the screen, with the correct aspect ratio". The 0 at the end is currently nothing, but I'll set that to be something like "1=Specifically a size, or 2=Fill with Ratio or 3=Fill the screen without care for Ratio"

Todo

Absolutely tons
My next task is to parse variables. Good lord, that's not going to be easy, is it!?!

-=-=-
''Load, Next List!''
Sun, 21 Feb 2021, 09:17
Jayenkai
Reasons for doing this..

The other day I had two events both shout and scream in my ear that I ABSOLUTELY should do this.

First, I was battling with a mini game idea and cursing myself that I'd have to code a great big Javascript game for what would essentially be a tiny little mini game. "Could do with a scripting engine, here, Jay!" I said..

Trying to calm myself down, and stop myself from giving myself insane amounts of work, I instead came over to SoCoder to think straight for a bit, at which point I got irrationally annoyed at Godot Online, because as much as it "is" online, it's kind of a pain in the arse, and you can't simple copy+paste code into it and see the code run..

So..
Yeah, two very different signs for essentially the same thing..

Ugh..
Am I really doing this!?!?
Fuxake..

-=-=-
''Load, Next List!''
Sun, 21 Feb 2021, 09:51
Pakz
I remembered this book that can be read for free online :

https://eloquentjavascript.net/12_language.html

This chapter teaches how to program a language. I bought a book on compiler programming a couple of years ago but it was beyond my skills. It only showed code to write a compiler(s) written in the authors own programming language.
Mon, 22 Feb 2021, 01:27
spinal
Sounds brain scrambling...
Mon, 22 Feb 2021, 08:22
Jayenkai
You know when you have a little idea, and then KABOOOM it's 70,000,000 times bigger overnight and you realise you have an absolute ton of stuff to do...

CBA today.. Have to make a bloody sprite editor and everything.. FFS!!!

-=-=-
''Load, Next List!''
Mon, 01 Mar 2021, 07:00
Jayenkai
Day Two..
.. Yes, Day Two.

I've spent the past week or so reading through various Lexer techniques, and wondering where/how to implement it.
I've opted to do a Compiler-esque Lexer parse at the star, parse the code, chop it into chunks, stick little flags all over the code, and then run the messy version in realtime.
It seems .. ok.. I think..



Although this screenshot appears identical to the previous one, the script is doing a lot more work in-between it being "a script" and being a semi-parsed script.

Next challenge, mathematicalising!!!

-=-=-
''Load, Next List!''
Mon, 01 Mar 2021, 11:01
spinal
If you want to port this to arduino and allow me to use it in a project, I won't stop you

-=-=-
Check out my excellent homepage!
Mon, 01 Mar 2021, 11:50
Jayenkai
LazyJaycode, right now. I'd likely have to triple-rewrite it, (that thing where you scrap and rewrite over and over to hopefully make it "better" each time) in order to reduce it to a small enough size for Arduino.
Currently there's a ton of string checks/comparisons, which wouldn't exactly be ideal on there.

-=-=-
''Load, Next List!''
Mon, 01 Mar 2021, 12:15
spinal
Only half serious It does sound like a useful project though.

-=-=-
Check out my excellent homepage!
Mon, 08 Mar 2021, 08:30
Jayenkai
I think I'm going to have to parse it myself, manually, oldskool style, going from chr 1 to chr strlen()..
I've tried to wrap my head around ways to do this, well, using Regex, but .. good grief...

Example..

Text Rand(0,100)+50*10,Rand(0,100+50),"This is \"Some Text\", which is "+RandFrom("nice","ugly","strong","a banana")+".",1

That's just way too fucking erratic, and I've spent far too long trying to strip that in different ways using Regex, to try and get the right sections to be in the right place, at the right time..
I just can't wrap my bloody head around it!!!

-=-=-
''Load, Next List!''
Fri, 12 Mar 2021, 07:54
AndyH
Don't know if this will be any help but the guy who wrote TRSE, before writing TRSE, learnt from this page: https://ruslanspivak.com/lsbasi-part1/

There are more that follow, and goes into all sorts.

-=-=-
Andy H
8-bit games at www.hewco.uk
Cartoons at awful.ovine.net
Ovine at ovine.net
Fri, 12 Mar 2021, 08:19
Jayenkai
I'm currently going slow, and taking my time figuring it out.
Lying awake at night thinking of ways to semi-compile things, so they're easier to process once the script has been loaded.
Kinda fun figuring it all out.. but.. yeah, I'm totally prepared to give up and follow a tutorial, instead

-=-=-
''Load, Next List!''
Wed, 24 Mar 2021, 14:00
Jayenkai




Crikey, that took some doing.
I finally made a good start on the rewrite, yesterday, and .. I think it's kinda working.
I at least now have access to all the strings on a line, as well as any other values, in the places they oughta be.

Brackets and strings exist as separate entities which are parsed before the rest of the line.
In the example above, two strings are now added to the quick example, both being fairly complex as far as brackets and quote marks go.

I haven't yet attempted to concatenate strings, or even do any of the main maths stuff. That'll come later! You might noticed I've stripped any and all maths from the test script.

For now, thankfully, the separation stuff is at least working. And that's a good thing. I think.. Maybe!!

At this rate, expect the next update to be some time in June!!

-=-=-
''Load, Next List!''
Sat, 27 Mar 2021, 08:40
Jayenkai
I started trying to add a bit of maths in, today, but it's not quite working as expected.

Need to do a bit more work on this current aspect, as I forgot to add argument values to the bracket/quote stuff.
Currently if I say..
Text 100,100,"This text here",1
it splits that into arguments 0,1,2 and 3.
But if I do..

Text 100,100,"This "+"Text "+"Here",1
it splits into 0,1,2,3,4 and 5. (Actually, it splits it into more than that, since the +'s also become arguments, too!!)

What I need to do instead is group things into..
0,1,2a,2b,2c,3
Then figure it out from there.
..
yep. Plenty more work to do!!

-=-=-
''Load, Next List!''
Thu, 01 Apr 2021, 20:45
Jayenkai
Day Five, I think, not sure.. Lost track..


View on YouTube

Magic!!!

The script that's running is here.


You can see the three left hand-centre numbers are..
Top - Sin(45)
Middle - Mills()
Bottom - Sin(Mills())

And.. As far as I can tell, that actually seems to be what's happening.
\o/yeay\o/

I need to sleep, now!! It's 3:45am!

-=-=-
''Load, Next List!''
Fri, 02 Apr 2021, 04:42
Jayenkai
Day Five point One!

Stress test.
Running on Edge, running in Windows, running on my old MacMini.

The line..

was added 200 times in the test script, and the script was run.
That's 2,000 Sin's!!
(Yes, I could do with a for-loop!!)

It currently takes an average of 15ms to generate each frame, running the 2,000 Sin's. I think that's OK.. 'ish.. Maybe!!!

I could definitely optimise that a little more, and have already considered one way to do it, although that might end up using more ram/giant arrays, in order to achieve the different methodology.
Hmmm..

I still haven't tackled maths or variables, yet.

-=-=-
''Load, Next List!''
Fri, 02 Apr 2021, 09:51
Jayenkai
Day Six



The line above is written in Reverse Polish Notation, and today I've realised why that exists!!
My challenge is now to get it to re-order "normal" maths so that it becomes the RPN, which it can then parse through fine.
I hope!!

Additionally, I need to get it to be a bit cleverer with maths sections.
It currently only "notices" maths is the maths is wrapped up inside brackets.

But.. Yeah, that line of code IS working. The Sin of Mills() is waving back and forth at the side of the screen!
Big Woot!!

Currently having issues with spaces getting screwy in the parser. Hmm..
Might have to strip out the spaces, throughout the script.

-=-=-
''Load, Next List!''
Fri, 02 Apr 2021, 11:19
Jayenkai
Day Six part two.

Tweaks to the interpreter.
Had some issues with spaces. In that if you write a,b,c it works fine, but if you write a , b , c then it fails.
Fixed that.. I hope!!

One thing that isn't working, right now, is multi-line commands. I don't think that's going to be happening, so .. don't do that, when I'm finished, 'cos it'll likely break!!

All the maths is still Reverse Polish Notation, but I've got floating point numbers working properly, and added SetAlpha into the mix to test it.
Oval, Circle and Tri/Triangle are all working commands, now, too!

-=-=-
''Load, Next List!''
Fri, 02 Apr 2021, 13:24
Jayenkai
Figured a command list might be useful, so started on one of those, today.
Linkage

Is this .. "readable"?
Is it OK?

-=-=-
''Load, Next List!''
Fri, 02 Apr 2021, 14:44
Dan
It is readable and it is ok - so far .
Sat, 03 Apr 2021, 04:17
steve_ancell
OK my end.
Sun, 04 Apr 2021, 06:40
Jayenkai
Day Six.5/Seven!



Comparisons are now mostly functional, all except "=".
Right now I'm assuming it's going to be bloody hard to tell an assigning "a=2" from a comparing "a=2", so I'm going to stick to == for = comparisons.
If, once everything's working properly, I can get that functioning, I will do. But for now, I'm making that particular function as easy as I can!

IF still isn't in, yet, though.
I'm going to need to handle if/endif and multi-line stuff for that to work. .. I think..?!

I could really do with figuring out the Reverse Polish Notation issue, first, though.

-=-=-
''Load, Next List!''
Mon, 05 Apr 2021, 06:30
Jayenkai
Day Eight


View on YouTube

Code - Click for bigger!

A hefty chunk of new commands, today.

Random numbers are in.
Float/Int/Ceil/Floor/etc are in.

Print is .. Half in. It will indeed print, like oldskool basic would, but it doesn't currently have a "don't put a newline" option. I'm not sure the best way to add that other than ,0 at the end.. That seems a bit weird. *shrugs*
Also, for the truest effect, the print command should really scroll the screen once it reaches the bottom, but I haven't coded that in, either!!

I still haven't wrangled the maths to be "normal" instead of RPN. I also haven't reduced my reliance on brackets, all over the flaming place!
But it's definitely getting closer to a functional language, which is nice.

Oh yeah, and the Graphics command has a third parameter, now. (The whole point of the video above!)
Set it to 0, and you get the resolution requested.
1 sets to the same resolution, but scales everything to be as big as will fit onto the browser's viewport.
2 will try to find a nice resolution with is "roughly" what you asked for, but that scales to fit the entire viewport. When using 2, you should use ScreenWidth and ScreenHeight to find the co-ordinates you should be aiming for..

eg, if you ask for 640x480, and the screen is 1920x1080, then your program will run at about 740x400.
It's up to you to figure out how to scale your code to fit that!!

-=-=-
''Load, Next List!''
Mon, 05 Apr 2021, 10:07
Jayenkai
Tested "Slap on a text area with a run button"

text area with run button works..
...
except..
Editing text in a text area is a right pain in the arse..
Try coding in this text area, and see how bad it is.

.. Looks like I'm going to have to code a sodding editor, too..
Grrrr..

-=-=-
''Load, Next List!''
Wed, 07 Apr 2021, 03:15
Pakz
I saw this blog/news/teaching site once that had these text area's elements with built in programming language. You could edit/create code on the webpage and run it too. I thought this was pretty cool and hoped these things would be used on more sites.

I'm curious to see what you are going to do with it You could make a whole playmycode thing!
Wed, 07 Apr 2021, 10:22
Jayenkai


Took me all pissing day, this did..

You can type..
You can tab, and Shift-Tab to unindent.
You can Ctrl+[ or Ctrl+] to indent/unindent, too.
You can Ctrl+S to save (it saves to your browser's LocalStorage)
Then I added a list of projects along the side, with the latest save bumping up to the top, just to give myself even more to do.
You can click through the different projects, Save, edit, run, close, save, etc.

And refreshing the page (ie accidentally hitting Ctrl+R!!!) will simply reload what you've got. No worries, there.

Gudgud...

Still no RPN fix yet, though.

Current "Main Test" code, if you're intrigued.
> Reveal 🔎

-=-=-
''Load, Next List!''
Page : 1 2 Next 3 4 5 6 7 8 9 10 11 12 13 14
Prev