Scripts written using ChatGPT

Creating scripts
Post Reply
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Scripts written using ChatGPT

Post by Graham Mills »

I thought I'd try scripting with ChatGPT. I was aware that it could generate code in Python, for eaxmple, but it turns out that it will generate LSL as well. It appears to recognise that OpenSim uses LSL and does a fair job of producing simple albeit generally non-functional code. I suspect the quality of the prompt has some bearing on the utility of the script although the AI does have some fairly fundamental misunderstandings, e.g. it confuses run-time permissions (e.g. llTakeControls) with object permissions.
e.g. "write a script for opensim that causes a prim to change colour from red to blue continually at 5 second intervals and become transparent after 30 seconds"

Code: Select all

integer elapsed_time = 0; // Keep track of the elapsed time

default
{
    state_entry()
    {
        // Set the initial color to red
        llSetColor(<1,0,0>, ALL_SIDES);

        // Set up a timer to change the color every 5 seconds
        llSetTimerEvent(5.0);
    }

    // This event is triggered every time the timer event occurs
    timer()
    {
        elapsed_time += 5; // Increase the elapsed time by 5 seconds

        // Toggle the color between red and blue
        if (llGetColor(ALL_SIDES) == <1,0,0>)
        {
            llSetColor(<0,0,1>, ALL_SIDES);
        }
        else
        {
            llSetColor(<1,0,0>, ALL_SIDES);
        }

        // If 30 seconds have elapsed, make the prim transparent
        if (elapsed_time >= 30)
        {
            llSetAlpha(0.0, ALL_SIDES);
        }
    }
}

It will also attempt to advise you on a strategy for solving a particular problem, e.g. "how would you get two npcs to chat with one another in an apparently intelligent fashion?"

Code: Select all

To get two NPCs (non-player characters) to chat with one another in an apparently intelligent fashion in OpenSim, you can use a combination of LSL and OSSL functions to create a script that simulates conversation between the NPCs.

Here is an example of how you could do this:

    Create two NPC avatars and give them each a script to control their behavior.

    In the script for each NPC, use the llListen function to listen for chat messages from the other NPC.

    When an NPC receives a chat message from the other NPC, use the osParseJSON function to parse the message and extract the relevant information.

    Use the llSay function to respond to the message with a predefined response, or generate a response using a combination of random selection and string manipulation.

    Use the osMakeNotecard function to save the conversation history to a notecard, so that the NPCs can refer back to previous conversations and continue the conversation intelligently.

By following these steps, you can create a script that allows two NPC avatars to have an apparently intelligent conversation with one another.

I hope this helps! Let me know if you have any questions or if you would like further assistance.
You can try it yourself https://chat.openai.com/
These users thanked the author Graham Mills for the post (total 5):
Ilan TochnerKimm StarrChris NamasteTony ElStory Link
User avatar
Mike Lorrey
Posts: 365
Joined: Sun Sep 04, 2016 5:40 pm
Has thanked: 72 times
Been thanked: 275 times

Re: Scripts written using ChatGPT

Post by Mike Lorrey »

an OpenAI GPT3 developer is a friend of mine, I've discussed with him having GPT3 run a bot avatar and work inworld as a helper and pointed GPT3 to the LSL wiki to study.
These users thanked the author Mike Lorrey for the post (total 3):
Graham MillsIlan TochnerGusher Castaignede
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Scripts written using ChatGPT

Post by Graham Mills »

Another option, currently free to use, is Phind. This not only produces a script but also explains its rationale and lists its sources.

https://www.phind.com/

Write an opensim script in LSL to add numbers from 1 to 50 and say the result on channel 0

Code: Select all

integer total = 0;
integer i;
for (i = 1; i <= 50; i++) {
    total += i;
}
llSay(0, "The sum of numbers from 1 to 50 is " + (string)total);
These users thanked the author Graham Mills for the post (total 2):
Ilan TochnerGusher Castaignede
User avatar
Gusher Castaignede
Posts: 260
Joined: Tue Mar 17, 2015 10:03 pm
Has thanked: 288 times
Been thanked: 252 times

Re: Scripts written using ChatGPT

Post by Gusher Castaignede »

...been trying a few aside from ChatGPT....it's insane! The AI will write the whole code you need...
Image
"lnteractivity, Variety, Ease of Use"
Visit my store at Country Manor
User avatar
Gregg Legendary
Posts: 123
Joined: Sun Jun 22, 2014 10:22 am
Has thanked: 214 times
Been thanked: 211 times

Re: Scripts written using ChatGPT

Post by Gregg Legendary »

I am interested in learning how to use AI scriptors can anyone make a youtube video detailing how to use them to write scripts for this forat, i looked at the ones mentioned and could not figure it out... yes im a dumbarse
These users thanked the author Gregg Legendary for the post:
Gusher Castaignede
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Scripts written using ChatGPT

Post by Graham Mills »

I'm afraid I haven't really kept up with developments. Someone who has (albeit with Python, not LSL) is Simon Willison and he gives his thoughts on the utility or otherwise of LLMs to new programmers in a recent podcast. TL;DR: he things it's useful.

https://simonwillison.net/2023/Sep/29/l ... rogrammers
These users thanked the author Graham Mills for the post:
Gusher Castaignede
User avatar
Gusher Castaignede
Posts: 260
Joined: Tue Mar 17, 2015 10:03 pm
Has thanked: 288 times
Been thanked: 252 times

Re: Scripts written using ChatGPT

Post by Gusher Castaignede »

If your a newb in LSL SCRIPTING start basic and
you will learn along the way with AI...

Start by asking the AI this question..

Hello, I have this lsl code for opensimulator below.
Can you modify it so that an object changes to
the color red when touching it?

Code: Select all

default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
}
Gregg Legendary wrote:
Sat Sep 30, 2023 9:03 am
I am interested in learning how to use AI scriptors can anyone make a youtube video detailing how to use them to write scripts for this forat, i looked at the ones mentioned and could not figure it out... yes im a dumbarse
These users thanked the author Gusher Castaignede for the post:
Gregg Legendary
Image
"lnteractivity, Variety, Ease of Use"
Visit my store at Country Manor
Post Reply