Return to “Scripting & Modding”

Post

How is LTSL written?

#1
Hello Josh,

I registered an account just to ask this question: how is LTSL written? Did you write the parser, interpreter etc from scratch in C++, or did you use good old 3rd party tools like bison, flex etc. to parse LTSL? I'm pretty sure it is not mentioned in the dev logs.

Thanks alot!
Post

Re: How is LTSL written?

#3
Welcome to the forums! :)

If he mentioned using a tool, I missed it too. But one nice property of Lisp-like languages is that they're very easy to interpret. The source code is already an abstract syntax tree! I wrote my own small Lisp in Python maybe six months ago, and had it working in a single Friday afternoon with a few last changes the following Sunday, made while I was using it to develop something else. A few things were in my favor: circumstances let me skip the lexing step, it's interpreted instead of compiled to something else, and it doesn't support macros. But writing a simple Lisp compiler from scratch with all the minimum special forms is completely feasible in just a couple days!

It's something people should try, I think. I learned a ton, and it's motivated me to add Common Lisp to my toolset. :D
Post

Re: How is LTSL written?

#5
thanks for your answers!

For me this is a coding miracle. At university you need one whole semester just to learn how to use flex and bison. And Josh simply hammers it down in one or two weeks (just besides everything else he does) :-) I just want to know where the cheat is. Maybe he designed the syntax in a way so compiling it is not a real issue?

One more question remains: is an LTSL script parsed every time a new object is created, or does Limit Theory produce some binary or intermediate code for every LTSL-Script?
Post

Re: How is LTSL written?

#6
Kazmirzak wrote:
One more question remains: is an LTSL script parsed every time a new object is created, or does Limit Theory produce some binary or intermediate code for every LTSL-Script?
The way Josh explains it is that LTSL scripts are periodically polled.
That way, in Dev Update #19, you can see that as soon as he saves the change for the LTSL script, the engine updates itself immediately.

He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.
YAY PYTHON \o/

In Josh We Trust
-=326.3827=-
Post

Re: How is LTSL written?

#7
FormalMoss wrote:He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.
If it ever gets to that, I'm sure Josh will add a parameter to allow a script to give itself a lower polling priority.
It's the smart thing to do, if you're relatively sure you won't be changing a script during play.
Beware of he who would deny you access to information, for in his heart he dreams himself your master.
Post

Re: How is LTSL written?

#8
He gets most of the LTSL from a large arcane book past down to him by the coding wizards of the long forgotten original Elder Council. Limit Theory is a kind of initiation test Josh is undertaking to gain admittance to their hallowed and august ranks.

:shifty: I think he may get a pass but it depends on how he handles the content section of the test. ;)
Post

Re: How is LTSL written?

#9
The ancient coding wizards! How could I forget about them!

Its so crystal clear now:
Spoiler:      SHOW
the coding 'cave' the mysterious day/night-rhythm (A day on mars is 24 hours 39 mins), surely he's not from earth. Considering this knowledge which he can only have gathered if he worked his whole life 24/7 or has some ingenious masters (or both) leads to the conclusion that he is hardly a human, so he must be one of the remaining beings of the marsian high civilsation (that one that almost got extinct due to global cooling)! Another proof: Actually Josh uploads all dev logs in time, they are just suffering the time delay from mars to earth, see, if he presses "submit" on mars, the update won't be on earth before 8 hours later. And it won't get better the following months, since in December this year mars and earth are in sun-conjunction - the farthest away from each other.
OMG it all makes sense now. Thanks Victor! :-)

P.S. Josh... no kidding... you wrote parser and compiler and interpreter for a complete language just by hand... in a week?
Post

Re: How is LTSL written?

#11
Kazmirzak wrote:OMG it all makes sense now. Thanks Victor! :-)
I forgot to welcome you to the LT forums, Kazmirzak. :wave: Sorry about that. I'm sure you will enjoy your time here. :D

Oh! And take no notice of what Cornflakes said. He thinks in human terms, he has little knowledge of the advanced devices the original EC possess. The ranks of the Council are filled with those supremely gifted individuals who are true Masters in a bewilderingly diverse collection of disciplines. Coding forms a small but significant part of the whole. :angel:

Josh may tell us more if he feels inclined to do so but the true EC jealously guard their privacy. They may decide he has revealed enough. ;)
Post

Re: How is LTSL written?

#12
Last viewtopic.php?f=12&t=3521&sid=e8bfe77b5 ... 77b#p64143 devlog:
Indeed, in the regular world of parsing massive languages with ambiguous grammars and so forth, it might not be such a simple thing. In the simple world of LTSL string lists, it took me one hour to have full-blown infix operators with correct precedence implemented in the language. The code that implements it is about 80 lines of C++. Simplicity pays off once again!
Ha! Now we know that Josh knows about the "regular world" of bison and flex, which uses "grammars" to describe a language. And now we also know he would rather hacks his own parser down in some plain C++ than use these crappy tools. :ugeek:
PS ~ I know, you're tired of hearing about LTSL [...]
@Josh: Any source code snippets for those guys that do like these dev logs? We are right here :wave: :wave:
Post

Re: How is LTSL written?

#13
Katorone wrote:
FormalMoss wrote:He also mentioned previously that having hundreds of individual script files could slow down the engine, but that's only at the extreme end of things.
If it ever gets to that, I'm sure Josh will add a parameter to allow a script to give itself a lower polling priority.
It's the smart thing to do, if you're relatively sure you won't be changing a script during play.
Better yet, use some sort of surveillance on the file that notifies LT of someone writing to the file. Then reload it.

In Windows:
http://msdn.microsoft.com/en-gb/library ... 85%29.aspx

In Linux, the inotify system might be useful (http://en.wikipedia.org/wiki/Inotify)
Post

Re: How is LTSL written?

#14
This is almost certainly already the case, the game watching for changes to the script files or folders.
Being slow from running many scripts wouldn't be related to them being changed though, it would be due to the pilling on of extra conditions for game logic and objects.
woops, my bad, everything & anything actually means specific and conformed
Post

Re: How is LTSL written?

#15
Writing a small interpreted scripting language isn't as hard as it sounds. I'm sure doing it from scratch is more fun than wrestling with a bison.^^ But the way he added not only a hot-loading custom scripting engine but also a full fledged, meticulously polished code editor that seamlessly integrates with the game app blows me away. Is that custom written too? It looks so beautiful!
Last edited by lithander on Mon Oct 20, 2014 4:04 am, edited 1 time in total.

Online Now

Users browsing this forum: No registered users and 9 guests

cron