#Im still having problems with this code.

62 messages · Page 1 of 1 (latest)

spice folio
#

kenLMP is undefined and it says that player1State is not defined. The line its refrencing is 487

 else if(!rightPressed && !leftPressed &&
        player1State.state != "kenLMP" &&
        player1State.state != "kenLMPMirror" &&
        player1State.state != "kenHP" &&
        player1State.state != "kenHPMirror" &&
        player1State.state != "kenLMK" &&
        player1State.state != "kenLMKMirror" &&
        player1State.state != "kenHK" &&
        player1State.state != "kenHKMirror"
        )

487 is the 2nd line, again i do not know what defined/ undefined means. Ive been following a youtube tutorial for this and ive gone through the entire code multiple times and I can't find anything wrong with it. I'm on the verge of pulling my hair out this is sooooo fustrating. plzzz help!

wind cobaltBOT
#

@spice folio

GENQCIDALSWOMAN 🇳🇿 Uploaded Some Code
Uploaded these files to a Gist
blissful wave
#

What HTML code thing???

spice folio
#

where it lets you send the code

blissful wave
#

It sent it as a file on GitHub...

spice folio
#

im gonna have to do it in parts because of the character limits

#

oh can you see the whole thing

blissful wave
spice folio
#

?

#

all 526 lines

blissful wave
#

Click the link, you can see the code yourself

spice folio
#

yup thats the whole thing

#

this is the error i keep getting

blissful wave
#

Can't tell you why it's undefined but I can tell you that it's only defined if the correct if/else if runs. So if the conditions are wrong it will not be defined. You need to figure out which condition you expected to define it but that didn't run.

spice folio
#

condition meaning the pixel frames or the else/if?

#

im sorry this must be annoying but im just really confused atm. ive been going through the code for 1+ hours now

#

i just started coding a few days ago aswell

blissful wave
#

You only define player1state inside of if/else if's. So if one of those that define it doesn't run it will be undefined.

spice folio
#

ok thankyou

latent torrent
#

let playerState = {state: "kenIdle", frames: 4, autoRepeat: false, nextState: "kenIdle"};

Isn't it this one that you're trying to reference?

#

At least according to your if/else if's, that's got all the states/frames/autorepeat/nextstate that you're checking

#

I'm guessing you'd fix it by changing that line to be let player1State instead

#

if(p1Frame >= player1State.frames && player1State.autoRepeat) for example, those all are in the playerState

spice folio
#

oh my god it was the line you refrenced but i forgot the 1 in player1State..... how did i miss it so so many times lol so much time wasted

latent torrent
#

Hahah, glad it was such a simple fix then

spice folio
#

thankyou btw

#

if you hadnt mentioned that line i wouldve gone mad probably

latent torrent
#

No problem, you don't have a linter that'd show you if you got unreferenced variables hanging around in the IDE/text editor you're using?

spice folio
#

nope dont even know what a linter is

latent torrent
#

What text editor/ide are you using?

spice folio
#

i just started coding a few days ago

#

notepad++

latent torrent
#

Linter basically checks the code and shows if there are potential errors in the code

spice folio
#

no ive just been checking it in chrome by inspecting

latent torrent
#

And, that's a text editor I haven't heard in a good while, hahah

spice folio
#

lol

#

i cant afford an IDE

latent torrent
#

VSC is free

spice folio
#

can it run java and c++ and C# ?

blissful wave
#

Yes

latent torrent
#

Yeah

spice folio
#

ok thankyou

latent torrent
#

(Sublime Text also got a free version, if you don't want to install VSC)

#

And afaik NP++ does have JSLint plugin for it as well

#

I just haven't used NP++ in forever

spice folio
#

im trying to learn how to code to get a headstart for when i apply to take a bachelor of computer science

#

ill go ahead and install VSC

latent torrent
#

Hahah, having a linter/IDE is gonna make that so much easier for you, no more pulling your hair out for having typos in your code, heh

spice folio
#

i know lol i did have a look at some other IDE's but they wanted like $200+ a year and i can't afford that atm

latent torrent
#

!tip ides

wind cobaltBOT
#
Recommended IDEs/Text editors

There are a large number of text editors and IDEs that you can use including online ones. Here are some that we recommend (note that there is no "perfect" IDE , they all have their pros and cons):

Basic:

  • IDLE (Included with Python installation)
  • Thonny (Great IDE for beginners)
  • repl.it (Browser IDE)

Extensible:

Integrated:

Notebooks (for data science or machine learning):

spice folio
#

thankyou

latent torrent
#

Those are mostly for Python, but VSC does do all of the languages you want

spice folio
#

okay thats very helpful thankyou

latent torrent
#

As does Sublime, but it's kinda, well, weird to get set up properly

blissful wave
#

Should probably update that to support other languages lol

spice folio
#

so do you code for a living?

latent torrent
#

Yeah, or get a more general IDE list as well

#

Zech does, I do cybersec/art/bodymodding

spice folio
#

nice

#

i wanna be a game dev