Just for fun > chatGPT and AGS scripts?

Started by Rik_Vargard, Fri 27/01/2023 13:38:06

Previous topic - Next topic

Rik_Vargard

I asked chatGPT if it knows AGS and yes it does  (laugh)

So I asked it to write me a basic script in AGS Script for a puzzle where you have to move a box to open a door.
To move the box you must use a lever but it's broken.
To repair de lever you need a wrench but the wrench is in a safe that has a code.

So it came up with this:

Code: ags
// Declare global variables
global.hasBoxMoved = false;
global.hasLeverRepaired = false;
global.hasSafeOpened = false;

// Attach script to "Use" event of lever object
if (event_type == EventType.Use) {
    if (obj == lever) {
        if (global.hasBoxMoved) {
            player.Say("The lever is already pulled.");
        }
        else if (global.hasLeverRepaired) {
            box.Move(x, y);
            global.hasBoxMoved = true;
            player.Say("You pulled the lever and the box moved!");
        }
        else {
            player.Say("The lever is broken.");
        }
    }
}

// Attach script to "Use" event of safe object
if (event_type == EventType.Use) {
    if (obj == safe) {
        if (global.hasSafeOpened) {
            player.Say("The safe is already open.");
        }
        else {
            var code = player.Input("Enter the code:");
            if (code == "1234") {
                global.hasSafeOpened = true;
                player.Say("The safe is now open.");
                if (player.HasInvItem(wrench)) {
                    global.hasLeverRepaired = true;
                    player.RemoveInvItem(wrench);
                    player.Say("You found the wrench and repaired the lever.");
                } else {
                    player.Say("You found the wrench, but you don't have it in your inventory.");
                }
            }
            else {
                player.Say("Wrong code, try again.");
            }
        }
    }
}

// Attach script to "Look" event of door object
if (event_type == EventType.Look) {
    if (obj == door) {
        if (global.hasBoxMoved) {
            door.ChangeRoom(room_id, x, y);
            player.Say("The door is now open!");
        }
        else {
            player.Say("The door is blocked by a big wooden box.");
        }
    }
}

It does precise things that must be adapted like declaring the objects.

Does this make sense?

Matti

#1
Ah, yes  :)

I also asked the chatbot about some AGS stuff a few weeks ago, and was impressed that it could help me (though things need to be adjusted)!

Rik Vargard

Quote from: Matti on Fri 27/01/2023 16:19:30Ah, yes  :)

I also asked the chatbot about some AGS stuff a few weeks ago, and was impressed that it could help me (though things need to be adjusted)!

Yep exactly :)... adjustments will be needed for obvious reasons.
Also, even if I see how it's working I don't have the experience to understand it fully ( my AGS Coding level).

And here's my thought :

I'm thinking about the AGS Team and the high level experts that are already taking so much time for AGS in a global way, and then taking even more time to help us out by replying on the technical forums. Even the more stupid basic things.
Always there.

Couldn't this be a tool, like the Manual and the GitHub thing, where people could be referred to?

eri0o

In my experiments with it, it makes too many mistakes still, often mixing AGS Script with some other languages (C, C# or JS), and also AGS API with other apis (even Game Maker stuff). Maybe at some point in the future but not right now.

One thing I had success with it is to pass AGS Scripts I had written and asking it to explain what the code did for me. This it works better, and can be helpful if you are trying to understand some code you made it yourself - but sometimes things are written deep in the night you forget about in the morning.

Matti

Quote from: eri0o on Fri 27/01/2023 21:57:24In my experiments with it, it makes too many mistakes still, often mixing AGS Script with some other languages (C, C# or JS), and also AGS API with other apis (even Game Maker stuff).

Definitely. You should treat the output as pesudo-code rather than actual AGS script. I think the chatbot can be helpful when it comes to a general code logic though.

Cassiebsg

#5
So... we're getting closer to the "Make my game" button in AGS editor be a reality instead of a joke! :D
There are those who believe that life here began out there...

Danvzare

Quote from: Cassiebsg on Tue 21/02/2023 16:09:43So... we're getting closer to the "Make my game" button in AGS editor be a reality instead of a joke! :D
You know, when I first saw that button, I legit thought it was an actual button that would ACTUALLY make a game for you if you pressed it. Using a bunch of procedural generation and basic templates, that kind of stuff.

It took me several months before I finally relented and pressed it, because I had my pride and wanted to make my own game by myself. But my curiosity got the better of me, and I figured I could maybe steal some assets from it.
It took me over a year after that to actually understand the joke.

I can be so very stupid.  (laugh)

KyriakosCH

I tried chatGPT too. It has its limitations, but certainly is great for confined/hierarchical systems (including code, if it has enough examples...)
It also helped me with some tricky Blender modelling (such as deforming stuff to parabolic or other functions).
This is the Way - A dark allegory. My Twitter!  My Youtube!

RickJ

Oopsie, I accidently reported eri0o to the mods, ... maybe.  I clicked the MORE button thinking I'd get more buttons to push.  I was actually looking for the LIKE button which I finally found. 

And yeah eri0o, I've had that same experience of writing some deep shit in the wee hours and wondering "WTF is this?".  The only thing worse is falling asleep halfway through and waking up not knowing how to finish or to get back to anerror free builds.  :grin:

SMF spam blocked by CleanTalk