[MZ]Script code created using Chat.openai

Decinbr

Regular
Regular
Joined
Mar 20, 2015
Messages
406
Reaction score
93
First Language
Portuguese
Primarily Uses
RM2k
Hello friend!
I asked the chat GPT to create a script code to show damage popup in map and worked, i just modified to use the coordenates numbers by variable.

var damage = 50; // replace with the desired damage value
var damageText = String(damage);
var x = Graphics.width / 2;
var y = Graphics.height / 2;
var color = '#ffffff'; // red color for damage text
var duration = 60; // duration of the damage display in frames

var damageSprite = new PIXI.Text(damageText, {fontSize: 24, fill: color});
damageSprite.x = $gameVariables.value(1);
damageSprite.y = $gameVariables.value(2);
SceneManager._scene.addChild(damageSprite);

var damageTimer = setInterval(function() {
duration--;
damageSprite.y--;
if (duration <= 0) {
SceneManager._scene.removeChild(damageSprite);
clearInterval(damageTimer);
}

}, 30);



I tried to create plugins but dont work
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,593
Reaction score
7,256
First Language
English
Primarily Uses
RMMZ
Getting into my thoughts on this would take a post all of their own. I'll settle for saying I don't think this is a good idea, I refuse to offer support on code that was written via a prompt, and I don't like how frequent it's becoming. But good luck with whatever you're trying to do with it.
 

TheoAllen

Self-proclaimed jack of all trades
Regular
Joined
Mar 16, 2012
Messages
7,495
Reaction score
11,669
First Language
Indonesian
Primarily Uses
N/A
I tried to create plugins but dont work
Wrap everything within
Code:
function YourScriptCall() {    
   <put the codes here>
}
Save as a plugin.
Use script call YourScriptCall()

And as Trihan said, you might get lucky this time that this looks like it "works" (funny that they use setInterval for popup lifetime when the game is fps based). But sometimes the AI can spout non-sensical code. By saying "I use OpenAI to generate" this, it implies "please fix this". I know you're trying to show that you can help yourself, but prominent programmers don't even need chat AI to make codes, they just need a clear requirement.
 

Sword_of_Dusk

Ace Attorney
Regular
Joined
Sep 13, 2015
Messages
1,545
Reaction score
1,651
First Language
English
Primarily Uses
RMMV
I'm not a coder, but I gotta say, this AI creating code thing is getting ridiculous. If you don't know how to fix whatever busted code the AI gives you, why is the first thought to come here asking for help? That's kinda fudged up in a way, at least in my opinion.
 

Kenen

Regular
Regular
Joined
Apr 3, 2012
Messages
500
Reaction score
767
First Language
English
Primarily Uses
RMMZ
This reminds me of being asked by a client to fix a "website theme" that they bought from an "online store." Sorry—can't do it, won't do it.

I get that the generated code might seem like an easier solution, but actually learning to code what you want to implement will serve you far better in the long run on many levels. Start small, learn bit by bit.
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,331
Reaction score
11,499
First Language
German
Primarily Uses
RMMV
@Decinbr
auto-generated code is the worst form of "cargo cult programming" possible, because there is no intelligence behind the code at all.
I suggest you read the excerpt in the following post to understand what that means - the link inside that post doesn't work anymore, but is not needed as the important parts were copied:
 
Last edited:

coyotecraft

Mythographer
Regular
Joined
Mar 13, 2012
Messages
502
Reaction score
276
First Language
English
Primarily Uses
N/A
@Decinbr
auto-generated code is the worst form of "cargo cult programming" possible, because there is no intelligence behind the code at all.
I suggest you read the excerpt in the following post to understand what that means - the link inside that post doesn't work anymore, but is not needed as the important parts were copied:
Computers are nothing but intelligence. I think you're conflating the word with consciousness, which is spirit. Ironically many programmers are also poor-in-spirit. It's frustrating because you'd expect them - of all people - to understand something so basic. So I don't blame people for turning to A.I. when the alternatives are these intellectuals who need more help from you than you need from them.
stackoverflow_hard_time.jpg
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,593
Reaction score
7,256
First Language
English
Primarily Uses
RMMZ
Computers are nothing but intelligence. I think you're conflating the word with consciousness, which is spirit. Ironically many programmers are also poor-in-spirit. It's frustrating because you'd expect them - of all people - to understand something so basic. So I don't blame people for turning to A.I. when the alternatives are these intellectuals who need more help from you than you need from them.
stackoverflow_hard_time.jpg
I really don't know what you're trying to say here.
 

GmOcean

Regular
Regular
Joined
Nov 29, 2020
Messages
195
Reaction score
161
First Language
English
Primarily Uses
RMMZ
The problem really isn't the AI program, it's the people using it while not having any coding knowledge. As usual, AI is a tool and if the person using the tool doesn't know what they're doing then bad things happen. In this case, unreliable code may be produced and that could cause errors in your project down the line.

I myself have used open.ai to create code for me, but I know enough to edit it to fix what doesn't work and what's not needed. But I definitely wouldn't use it for strictly rpg maker code, basic javascript functions sure. After all it's much easier and faster to tell it create an Array[X][Y] using given variables make comparisons and spit out a returned array I can use. While it makes it's pretty good spaghetti code in ~30 seconds (faster than any human realistically could), I can grab a cup of coffee, come back to a finished script, and make changes.

Again, it's a tool, but if you can't already do what it does at the basic level, you probably shouldn't use it for that use case. Can't use a hand saw? Definitely don't use an electrical one.
 

coyotecraft

Mythographer
Regular
Joined
Mar 13, 2012
Messages
502
Reaction score
276
First Language
English
Primarily Uses
N/A
If we forbid the socially inept from using social platforms they wouldn't grace us with solutions like "git gud" or demonstrate their mastery of problem-solving skills by avoiding problems all together.
They wouldn't spiral up their own butts into the imaginary number plane. Popping back inside-out thirsty for gratitude and appreciation; only to receive none. They wouldn't reap the same "common sense" they sowed. They wouldn't taste their own medicine. They wouldn't know how horrible it is to "deserve" help because they wouldn't be allowed in public to eat their own pretenses like a pie to the face.
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,593
Reaction score
7,256
First Language
English
Primarily Uses
RMMZ
If we forbid the socially inept from using social platforms they wouldn't grace us with solutions like "git gud" or demonstrate their mastery of problem-solving skills by avoiding problems all together.
They wouldn't spiral up their own butts into the imaginary number plane. Popping back inside-out thirsty for gratitude and appreciation; only to receive none. They wouldn't reap the same "common sense" they sowed. They wouldn't taste their own medicine. They wouldn't know how horrible it is to "deserve" help because they wouldn't be allowed in public to eat their own pretenses like a pie to the face.
This has in no way helped my understanding of your point.

If I'm parsing it correctly (and I'd be very surprised if I am) what you're saying is that it's immoral for us to refuse someone help on the basis that they didn't write the code themselves because they're still asking for help.

But it's not a superiority thing. I'm not refusing because I think I'm better than the person asking; I'm refusing because I view generating code with AI as involving an unnecessary middle man that creates more problems than it solves. If they'd just been like "I need to know the code required to accomplish X" I'd have provided it. But I'm not going to take ChatGPT's output and turn it into real code.

I also don't help anyone here for gratitude or appreciation. If I were looking for that, I'd just go and do something entirely different from this. :p
 

TheoAllen

Self-proclaimed jack of all trades
Regular
Joined
Mar 16, 2012
Messages
7,495
Reaction score
11,669
First Language
Indonesian
Primarily Uses
N/A
@coyotecraft
if you can illustrate the problem from the programmer's perspective on what went wrong like how GmOcean does, that would help. But if you're here just criticizing from a different perspective, you're hijacking someone's post. You should post this in Site Feedback or something (so we can focus on your point and not derail the thread). Otherwise, talk to the OP and/or solve their problem. Suggest a plugin or write the code for them.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,270
Reaction score
9,266
First Language
English
Primarily Uses
RMMV
But it's not a superiority thing. I'm not refusing because I think I'm better than the person asking; I'm refusing because I view generating code with AI as involving an unnecessary middle man that creates more problems than it solves.
I agree with this. In order to make sure AI code is correct, someone who knows what they're doing literally has to go over every line - I've seen random junk just stuffed into the middle of functions.

If that's what has to be done, then there's almost no difference between that and simply having someone who knows what they're doing write it in the first place.

I don't know what @coyotecraft is trying to express. Whatever opinion the posts have is couched in such abstract snark that the actual intent is unintelligible. If they're solely written as entertainment because it's fun for you to write that way, that's cool. If you're actually trying to share something with other people, you might want to tone it down because you're failing in your goal.
 

Poryg

Dark Lord of the Castle of Javascreeps
Regular
Joined
Mar 23, 2017
Messages
4,233
Reaction score
11,318
First Language
Czech
Primarily Uses
RMMV
I don't work with MZ, so I won't provide an overly useful answer. However, the generated code is trash.

The AI uses local variables. These local variables will get undefined once the function call finishes.
On top of that, it uses setInterval. A function that, for its call, resets both the local and global context. Making any local variables inaccessible even if you define it inside a function.
If you want it to work, you'd generally want to make all this part of the Scene_Map class.
 

coyotecraft

Mythographer
Regular
Joined
Mar 13, 2012
Messages
502
Reaction score
276
First Language
English
Primarily Uses
N/A
@Trihan
They did ask that. You're just operating within a literal extreme of the question's framework. Which doesn't help distinguish you from the A.I. you're condeeming.
The way I see it, you're just creating your own problem that you can solve by being that middleman.

@TheoAllen
While I respect your want for board integrity. I've been here long enough to know that the forums are a social platform first and foremost. I can't even post my own feedback without a including a poll or formatting it in a way to foster "discussion" and/or debate 9_9. So your disapproval of this tangent (which I didn't not start) is not conductive to that purpose; not to mention hypocritical.
Demanding a "programmer's perspective" is invalid; especially in this case when it's a program that is also the programmer contrasted against humans with equally inflexible set of rules.

As, ATT_Turan pointed out, AI can't learn without input. The same goes for humans, assuming they don't have a learning or social impairment. The only thing you have to worry about is if I play along with their impairment and continuing to humor the posts that insist they "don't understand". If only to have them prove my point for me. Their truth has always been betrayed by their other perceptions.
It's not like they haven't been the subject of a dozen Site Feedback threads in the past.

If you think criticizing someone process is bad. You must understand how obnoxious it when people "validate" results, and set new goals, in the absence of understanding.

Or, how about when they disagree with your vocabulary? It's not their word choice. But they insist on "correcting" you anyways. Again. How can they know but not-know what someone means?
Oh~ "loop" means something else out-of-context. Yeah. It's also been a verb for centuries. That kind of "programmer's perspective" is dumb. They will waste people's time "teaching" people how to talk to them as if they were a computer. They're not!

If their people skills came from talking to computers, you're not doing any favors shielding them from criticism. Their aptitude for programming might come from their one-track mind. But God forbid A.I. develope prudence before they do.
 

TheoAllen

Self-proclaimed jack of all trades
Regular
Joined
Mar 16, 2012
Messages
7,495
Reaction score
11,669
First Language
Indonesian
Primarily Uses
N/A
I've been here long enough to know that the forums are a social platform first and foremost.
While most of the part is true (general discussion, game mechanic, profile post, etc), you are in a Q/A forum, which is less about being "social", but answering a question, which is also understandable because it is a tiny fraction of this whole "social platform". Just pointing this out

I'm not gonna respond to your other point, except maybe if you start being less defensive and/or you're making your own thread on "what is your problem with people here".

... you know what, I might want to start a topic about this sometime later. (Edit: we can continue here)
 
Last edited:

Another Fen

Regular
Regular
Joined
Jan 23, 2013
Messages
697
Reaction score
395
First Language
German
Primarily Uses
I tried to create plugins but dont work
I only have the MV at hand right now, but your code seems to work fine there, and since it uses the same libraries in that regard I would expect it to work in MZ too.
Since you said the original worked fine, what exactly did you change? Did you make sure your variables have plausible values (you need screen pixel coordinates here)?

I'm assuming you are running that code as an event script command.

I don't work with MZ, so I won't provide an overly useful answer. However, the generated code is trash.
Not sure I would go that far here.
I don't mean the code could not probably be improved, but it should do its job.

You cannot access local variables from outside the function call that created them, but since this is a custom UI element I would argue that it's unlikely any code would need to interact with it anyways.

Accessing SceneManager.scene in an event can cause undesired effects if you are in the middle of a scene change though of course (if you are using the script code in a parallel process for instance).
 

TheoAllen

Self-proclaimed jack of all trades
Regular
Joined
Mar 16, 2012
Messages
7,495
Reaction score
11,669
First Language
Indonesian
Primarily Uses
N/A
@Another Fen
Correct, the code should work without a problem (I haven't tried, but the code looks "fine"). I'm not sure what happened if you change the scene before the popup expires though, but I assume it wouldn't be a problem either. That is why I only suggest wrapping everything under the function so that you can use the script call. This dude is lucky enough to get AI code that is actually working, but I certainly don't want this to become a norm.
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
3,076
Reaction score
6,246
First Language
english
Primarily Uses
RMMZ

Let's keep the thread focused on the topic, people. If you want to discuss the troubles with AI codes, please do it in another thread, such as this one.

 

Zeriab

Huggins!
Regular
Joined
Mar 20, 2012
Messages
1,405
Reaction score
1,617
First Language
English
Primarily Uses
Other
I'm curious. What did happen when you asked the ai to turn the resulting code into a plugin?
 

Latest Threads

Latest Profile Posts

Oooeee, not me drawing very dynamic poses I’ve never drawn before. Oooooeeee. I’ve gone too far and now I need to furiously find reference images.
Work in progress Farm. I borrowed the chickens from the default character sheets and ballooned them in size. The Mv sprites are really pretty when enlarged. Though they are place holders for now. I'm toying with the idea of making an actual farming mechanic and not just having a farm for cosmetic reasons. The barn was inspired by Sword of Mana.

16-bit top-down pack coming soon... \( ̄︶ ̄*\))
Follow the progress here.

zzDxGY3.png
jWfg2Sn.png
dWQyTRH.png
Fixed an error in my icon set, and did a full custom button set.
What do you call a vampire doctor? Dr. Acula.

Forum statistics

Threads
135,026
Messages
1,253,087
Members
177,964
Latest member
datgoodnooch
Top