Jump to content
You are about to reply to a thread that has been inactive for 1594 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted (edited)
string source = "%22;%0A%0A// Hello, world!%0A%0Adefault%0A{%0A    state_entry()%0A    {%0A        integer answer = 42;%0A        llOwnerSay(llUnescapeURL(%22string source = %2522%22) + source + llUnescapeURL(source));%0A        llOwnerSay((string)answer);%0A    }%0A}";

// Hello, world!

default
{
    state_entry()
    {
        integer answer = 42;
        llOwnerSay(llUnescapeURL("string source = %22") + source + llUnescapeURL(source));
        llOwnerSay((string)answer);
    }
}

This ("quine") is code that outputs its own source-code. Not just everything in the default state, but also the comment and the global variable with its contents.

A much simpler method would be to write a notecard reader, then copy-paste the script's content into a notecard and make the script output that notecard. External data is boring, though!

If you were to compare the output from local chat with the source code in the script, it isn't even one character off. 🎉

46af10ee8c.png

Edited by Wulfie Reanimator
  • Like 2
Posted

is pretty interesting doing these kinds of things

next challenge is to write an interpreter in LSL that will execute a LSL syntax program. Writing an interpreter is usually part of the CS education curriculum and can be quite fun to do

there are some language interpreters that residents have written in LSL here: http://wiki.secondlife.com/wiki/CatInterpreters

i like them all for the different flavours/approaches they bring, but I like Subus Tremor's RPN Interpreter the most for its simplicity

Posted (edited)
11 hours ago, Mollymews said:

is pretty interesting doing these kinds of things

next challenge is to write an interpreter in LSL that will execute a LSL syntax program. Writing an interpreter is usually part of the CS education curriculum and can be quite fun to do

there are some language interpreters that residents have written in LSL here: http://wiki.secondlife.com/wiki/CatInterpreters

i like them all for the different flavours/approaches they bring, but I like Subus Tremor's RPN Interpreter the most for its simplicity

I've had to implement Brain***** more than once across several exams... No idea how I'd even begin to do it in LSL since we don't have anything even close to pointers or character/ascii-value conversions.

The assembly interpreter is a pretty good example of how ill-suited LSL is for this them. 

Edited by Wulfie Reanimator
Posted

where short program interpreters can be helpful is in quest-like games, NPCs and other automations

our NPC/automation can carry out tasks written in our language, stored as strings in notecards/web server. So that we don't have to compile a new LSL script whenever we give our NPC/automation a new task that it can perform

same with quests, our player HUD has an interpreter. New quests can be added to the game without having to change the code in the players HUD or on the gameplay director/sentinel

our own little version of a runtime scripting language, a capability we find in game engines


a thing I notice sometimes in SL. People make a quest-like game and they approach it like they are making a board game - fixed actions, pathways and goal - hardcoded in LSL

when as a SL game maker, a more complete approach is to make it like a game engine of which a language interpreter (its brain) is the central component

when we do this then creating new and updating existing quest-like games is a whole lot easier and simpler. We can write all our new/updated game logic in our language saved as strings. Feed these to our NPC / player HUD / Sentinel brains, and off they go to complete their new tasks

You are about to reply to a thread that has been inactive for 1594 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...