Log In  
Follow
Mr_Pancake1124

I'm having issues with this code, everytime I run it i just get this


runtime error line 34 tab 3
if collide_map(player,"down",0) then
attempt to call global "collide_map" (a nil value)

here's my code:

--external functions--
function dns(sp)
	spr(sp.sp,sp.x,sp.y,sp.w/8,sp.h/8,sp.flp)
end

function player_update()
	--physics
	player.dy+=gravity
	player.dx*=friction

	--running
	if btn(⬅️) then
		player.dx-=player.acc
		player.running=true
		player.flp=true
	end
	if btn(➡️) then
		player.dx+=player.acc
		player.running=true
	end

	--jumping
	if btnp(🅾️) and player.landed then
		player.dy-=boost
		player.landed=false
	end

	--collision on y axis
	if player.dy>0 then
		player.falling=true
		player.landed=false
		player.jumping=false

		if collide_map(player,"down",0) then
			player.landed=true
			player.falling=false
			player.dy=0
			player.y-=(player.y+player.h)%8
		end
	elseif player.dy<0 then
		player.jumping=true

		if collide_map(player,"up",0) then
			player.dy=0
		end
	end

	--collision on x axis
	if player.dx<0 then
		if collide_map(player,"left",0) then
			player.dx=0
		end
	elseif player.dx>0 then
		if collide_map(player,"right",0) then
			player.dx=0
		end
	end

	player.x+=player.dx
	player.y+=player.dy
end
--function player_animate()
--end

here's just the section its calling out:


collide_map(player,"down",0) then
player.landed=true
player.falling=false
player.dy=0
player.y-=(player.y+player.h)%8

can anyone help me out with this

4 comments