Variable gets set to nil when it shouldn't

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Jipjang
Prole
Posts: 2
Joined: Fri May 24, 2024 7:04 am

Variable gets set to nil when it shouldn't

Post by Jipjang »

I'm making a Mario like platformer level editor and I'm currently working on customizable enemies and objects. But when an enemy transforms it should have the same movespeed that it had before. But for some reason, it gets set to nil.

Code: Select all


local transformedfrom = obj.transformedfrom
local koopa = OBJECTS:transform(i, obj, 16)
koopa.vx = 0
koopa.vy = 0
koopa.invincframes = 14
print(transformedfrom[2].mvspd) --prints 4
koopa.mvspd = transformedfrom[2].mvpsd --for some reason koopa.mvspd gets set to nil instead
if obj.x > PLAYER.x then
	koopa.facing = -1
else
	koopa.facing = 1
end
if obj == PLAYER.holding then
	PLAYER:die()
end
obj.type = "dead" --deletes the original object

User avatar
marclurr
Party member
Posts: 146
Joined: Fri Apr 22, 2022 9:25 am

Re: Variable gets set to nil when it shouldn't

Post by marclurr »

Read this line really carefully.

Code: Select all

koopa.mvspd = transformedfrom[2].mvpsd
Jipjang
Prole
Posts: 2
Joined: Fri May 24, 2024 7:04 am

Re: Variable gets set to nil when it shouldn't

Post by Jipjang »

marclurr wrote: Fri May 24, 2024 4:31 pm Read this line really carefully.

Code: Select all

koopa.mvspd = transformedfrom[2].mvpsd
Yeah I just noticed bruh
User avatar
dusoft
Party member
Posts: 635
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Variable gets set to nil when it shouldn't

Post by dusoft »

Jipjang wrote: Fri May 24, 2024 6:02 pm
marclurr wrote: Fri May 24, 2024 4:31 pm Read this line really carefully.

Code: Select all

koopa.mvspd = transformedfrom[2].mvpsd
Yeah I just noticed bruh
Maybe use editor that does some basic checking, bruh.

Also you forgot to say thanks, bruh.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests