basic but functional squirrel script created with ChatGTP

Creating new content for Trespasser!

Moderators: TresCom Support Team, TresCom Board Managers, TresCom Developers

Post Reply
morningstarring
Brachiosaurus
Brachiosaurus
Posts: 196
Joined: Wed Jul 22, 2020 12:59 am

basic but functional squirrel script created with ChatGTP

Post by morningstarring »

So I wanted to give squirrel script a try. I use ChatGTP to help write code in Python and it produces pretty good code, so I thought I'd try to see how it does with squirrel. I pasted some readme files from TresCE's Doc folder on scripting into ChatGTP to help it write squirrel script Trespasser would hopefully understand. after about an hour of trial and error, pasting errors into ChatGTP and having it rewrite code over and over, I was able to generate a functional squirrel script. all it does is print "You Jumped" on screen after pressing the jump key. sometimes you have to press jump twice like a double click to get it to work(not sure why) but its a start. here's the code.

Code: Select all

// Define a GameScript class to handle player jump event
class JumpMessageScript extends GameScript {

    // Called when a script instance is created
    constructor() {
        print("JumpMessageScript initialized.");
    }

    // Function to handle player input
    function OnHandleInput() {
        // Check if the jump key is pressed
        if (bKeyHit(uCMD_JUMP)) {
            // Display the message "You jumped" on the screen for 5 seconds in white color
            TP_Engine.u4DisplayFormattedString(
                "You jumped",         // Text to display
                5.0,                 // Duration (in seconds)
                0,                   // Formatting flags (0 for default)
                TP_Engine.rgb(255, 255, 255), // Color (white)
                0,                   // Previous handle (optional, can be 0)
                ETextType.ettUNKNOWN  // Text type (optional, use default here)
            );
        }
    }
}

// Create an instance of the script to activate the input event handler
local jumpMessageScript = JumpMessageScript();
I'm trying to get ChatGTP to write some more advanced scripts but while it seems to know squirrel really well, it doesn't know or remember to keep trespasser syntax in mind, or understand trespasser in general. Maybe with better prompts it'll get easier to produce some crazy squirrel scripts soon. anyway just thought id share. Also if y'all have any working squirrel scripts to use as examples that would help a lot. I searched the forum but only found a couple examples. wish me luck!
User avatar
Draconisaurus
T-Rex Killer
T-Rex Killer
Posts: 14301
Joined: Mon Dec 06, 2004 5:21 pm
Antispam: No
Location: Isla Sorna
Contact:

Re: basic but functional squirrel script created with ChatGTP

Post by Draconisaurus »

Interesting. Sadly the squirrel script function of CE doesn't seem to work on all computers. That is to say, script that shows up ingame on one computer may not show up ingame on another computer. Still nice for those who get to see it.
User avatar
tatu
-=TresCom Website Manager=-
-=TresCom Website Manager=-
Posts: 5297
Joined: Fri Jun 24, 2005 9:40 pm
Antispam: No
Location: Sweden
Contact:

Re: basic but functional squirrel script created with ChatGTP

Post by tatu »

Cool, hopefully it will become better at that. I believe an example of printing out a text is something I've read the tutorial for it, or CE includes.

Sadly we don't have many scripts as no-one has really manage to make something out of it :/
Active project: Trespasser: Isla Sorna
Status:
BE-PH1: Released
PH2-IT: Pre-released
PL-SUM: In production

"...there used to be more benches, but InGen's workers removed them during the evacuation in the name of framerate."
morningstarring
Brachiosaurus
Brachiosaurus
Posts: 196
Joined: Wed Jul 22, 2020 12:59 am

Re: basic but functional squirrel script created with ChatGTP

Post by morningstarring »

tatu wrote: Wed Sep 11, 2024 5:47 pm Cool, hopefully it will become better at that. I believe an example of printing out a text is something I've read the tutorial for it, or CE includes.

Sadly we don't have many scripts as no-one has really manage to make something out of it :/
there are some specific chatGTP frameworks that are built to interpret a programs source code and can pull info from a github URL. I tried it with the trespasser source code on github, but it still seemed to struggle to make sense of how all the code was connected. maybe just because Tres code is difficult in general lol. still with a little patience and prompt engineering from the trespasser source code and squirrel API, I think some really interesting/complex stuff could be added into Tres. If I am able to make some interesting scripts I'll post them here and post the series of ChatGTP prompts that created the functional code. I think that would help any modders in the future. having more examples of functional squirrel script in tres will really help AI create functional code. I'd love to see a Trespasser revival, maybe squirrel script could be the key.

while I love this forum and it's small dedicated community, I wish it had a slightly larger audience. dunno if Tres will ever be redeemed, maybe one day though. :)
Teromen
Parasaurolophus
Parasaurolophus
Posts: 259
Joined: Sun Jun 25, 2017 11:48 pm

Re: basic but functional squirrel script created with ChatGTP

Post by Teromen »

Do you think AI could lead to new render code? One of my targets would be dynamic shadows on all objects. I was thinking a sort of megatexture effects on models but you know... not gonna happen lol. I wonder if AI can port trespasser completely over to a new engine with little errors to fix?
morningstarring
Brachiosaurus
Brachiosaurus
Posts: 196
Joined: Wed Jul 22, 2020 12:59 am

Re: basic but functional squirrel script created with ChatGTP

Post by morningstarring »

Teromen wrote: Sat Sep 14, 2024 6:32 am Do you think AI could lead to new render code? One of my targets would be dynamic shadows on all objects. I was thinking a sort of megatexture effects on models but you know... not gonna happen lol. I wonder if AI can port trespasser completely over to a new engine with little errors to fix?
not at the moment really. It could help but significant human input and oversight from those with advanced domain knowledge would be needed for something like that. given all the investment in gen ai who knows what will be possible over the next 5-10 years.
User avatar
TheIdiot
T-Rex
T-Rex
Posts: 4620
Joined: Thu Feb 20, 2014 9:13 pm
Antispam: No
Location: Canada, eh?

Re: basic but functional squirrel script created with ChatGTP

Post by TheIdiot »

morningstarring wrote: Wed Sep 11, 2024 1:02 am I'm trying to get ChatGTP to write some more advanced scripts but while it seems to know squirrel really well, it doesn't know or remember to keep trespasser syntax in mind, or understand trespasser in general. Maybe with better prompts it'll get easier to produce some crazy squirrel scripts soon. anyway just thought id share.
That's kind of the general issue with generative stuff like this, it doesn't really know anything outside of what it's absorbed into its database, so trying to get it to process secondary elements like the Trespasser-specific elements is going to be tricky. It's good at doing things that it has full information on but is completely incapable at extraoplating upon that (which is why it isn't really artificial "intelligence" in any way). It will probably be good for generating a base-script if we can figure out what needs to be changed in order to make it work in Trespasser, however. Even just getting it to process that you jumped is incredibly useful, because if we can figure out how to work from what is given here, we can start scripting additional elements involving the pushing of a key.
morningstarring wrote: Wed Sep 11, 2024 1:02 am Also if y'all have any working squirrel scripts to use as examples that would help a lot. I searched the forum but only found a couple examples.
I might be the only one who has used them in my levels, you can find everything Lee Arbuco scripted for me in the final RTJP release. There are a few scripts in there which I re-named to make them more obvious in their function. The Player script contains both the functionality for the HUD as well as for the stamina system.
Teromen wrote: Sat Sep 14, 2024 6:32 am Do you think AI could lead to new render code? One of my targets would be dynamic shadows on all objects. I was thinking a sort of megatexture effects on models but you know... not gonna happen lol. I wonder if AI can port trespasser completely over to a new engine with little errors to fix?
The issue with Trespasser is how complex the source code is, apparently - it's not coded like anything else out there, which is bad for generative stuff like this because it by nature requires to have been fed specific information pertaining to Trespasser's code. It can probably port elements of it but getting the entire thing together would be a challenge without having people around to supervise it. And even then it would probably do things wrong here or there, and those would require manual fixing. Look at engine ports like OpenMW and OpenRCT2, they're not exact 100% ports in many areas, but the casual player is never going to know this as it is all largely under-the-hood stuff done to make the developer's lives easier. So I would suspect that a mostly computer-generated Trespasser code, what with the complexity of the engine, would probably have some elements that just aren't quite "right" and would need manual fixing if you wanted to make it close to the original.
My releases: Click Here! | "Paper is dead without words; Ink idle without a poem; All the world dead without stories; Without love and disarming beauty."
Image
morningstarring
Brachiosaurus
Brachiosaurus
Posts: 196
Joined: Wed Jul 22, 2020 12:59 am

Re: basic but functional squirrel script created with ChatGTP

Post by morningstarring »

TheIdiot wrote: Sat Sep 14, 2024 6:07 pm That's kind of the general issue with generative stuff like this, it doesn't really know anything outside of what it's absorbed into its database, so trying to get it to process secondary elements like the Trespasser-specific elements is going to be tricky. It's good at doing things that it has full information on but is completely incapable at extraoplating upon that (which is why it isn't really artificial "intelligence" in any way). It will probably be good for generating a base-script if we can figure out what needs to be changed in order to make it work in Trespasser, however. Even just getting it to process that you jumped is incredibly useful, because if we can figure out how to work from what is given here, we can start scripting additional elements involving the pushing of a key.
I'll see if i can paste the prompts I used to get it to make the jump script in the next reply.
TheIdiot wrote: Sat Sep 14, 2024 6:07 pmI might be the only one who has used them in my levels, you can find everything Lee Arbuco scripted for me in the final RTJP release. There are a few scripts in there which I re-named to make them more obvious in their function. The Player script contains both the functionality for the HUD as well as for the stamina system.
Thanks I'll take a look at that level and see if I can do anything with the scripts.
TheIdiot wrote: Sat Sep 14, 2024 6:07 pmThe issue with Trespasser is how complex the source code is, apparently - it's not coded like anything else out there, which is bad for generative stuff like this because it by nature requires to have been fed specific information pertaining to Trespasser's code. It can probably port elements of it but getting the entire thing together would be a challenge without having people around to supervise it. And even then it would probably do things wrong here or there, and those would require manual fixing. Look at engine ports like OpenMW and OpenRCT2, they're not exact 100% ports in many areas, but the casual player is never going to know this as it is all largely under-the-hood stuff done to make the developer's lives easier. So I would suspect that a mostly computer-generated Trespasser code, what with the complexity of the engine, would probably have some elements that just aren't quite "right" and would need manual fixing if you wanted to make it close to the original.
Not only is the code complexity an issue it's "unfinished" state, unused code, and buggy nature would be problematic to work with.
Post Reply