I'm having trouble with the draw_player function and it's showing an error saying that the "P" variable is a nil value whenever I run the game, I'm sure I put in your script exactly as it shows in your video can you help me fix this?
A thought, for the map co-ordinates to pixel co-ordinates conversion, you could pre-calculate them and then use a lookup table, using the map co-ordinate as the key and the pixel co-ordinate as the value. Also I honestly like how you described the braces for creating an object as "A big hug", I've honestly never thought about it that way but I like it. Subscribed!
My characters Y value isnt changing when i change the p.y value in the make player function nor can i move it up or down when i follow the next tutorial. any help?
what if my player is bigger than just one tile? if it is 2x2 i mean.. how do i type that out instead? or where can i find that information? thank you and great video
A couple things to make sure of are that your draw_player() function is _after_ your draw_map() function, and then also make sure that your p.sprite variable points to the sprite number where you made your player sprite. In my example, I drew my player using sprite 1, so I set p.sprite to 1. But if your player sprite is on, say, sprite 5, then you would need to set p.sprite to the number 5. If that still doesn't work, let me know.
Im even later, but I’m having the same problem, my draw_player is under my draw_map and the player sprite number is entered correctly so I have no idea what to do next.
Usually that error means there's a typo in the name of either the draw_map() function on Tab 1, or where you tell it to run the draw_map() function in the _draw() function on Tab 0. Feel free to copy/paste your Tab 1 and Tab 0 code here into a reply if you take a look and don't see anything wrong.
@@DylanBennett Tab 0 "--gameloop --runs one time function _inite() map_setup() make_player() end --runs again and again every 30 sec function _updates() end --runs as _updates, but only after it. function _draw() cls() draw_map() draw_player() end" Tab1 "--map function map_setup --map tile settings wall=0 key=1 door=2 anim1=3 anim2=4 lose=6 win=7 end
@@rbernhardsson9857 I see a few things to fix! All of them are small, but they will really throw a monkey wrench into things. First, you have an extra "e" on your _init() function name. (Should be "_init()" instead of "_inite()".) Second, there's an extra "s" in your _update() function name. (Should be "_update()" instead of "_updates()".) Lastly, you need to make sure to add the parentheses to the end of your map_setup() function. Right now it says, "function map_setup", but it should say, "function map_setup()". I hope that helps! If you are still running into issues, please let me know. Don't get frustrated over little typos like that either. Little things like that are easy to miss and super common (even for programmers that have been programming for literally decades).
I'd be happy to help if I can. Can you post the code you have put in already for tabs 0 and 2? Also, make sure you are running make_player() in your _init() function in tab 0. And then also make sure draw_player() is in the _draw() function.
@@DylanBennett This is in Tab 0: --game loop function _int() make_player() map_setup() end function _update() end function _draw() cls() draw_map() draw_player() end This is in Tab 2: --player code function make_player() p={} p.x=3 p.y=2 p.sprite=16 p.keys=0 end function draw_player() spr(p.sprite, p.x*8, p.y*8) end
@@DylanBennett Getting the same error, no typo, my code: TAB 0: function init() map_init() player_init() end function _update() end function _draw() cls() draw_map() draw_player() end TAB 2: function player_init() p={} p.x=3 p.y=2 p.sprite=64 end function draw_player() spr(p.sprite,p.x*8,p.y*8) end EDIT: OOPS! map_init and player_init round the wrong way ! EDIT2: Still doesn't work...
@@lounowell4171 Just one little missing character! The first function is supposed to be _init() but it looks like you have just init() instead. (Not the missing _ character.)
THESE ARE THE MOST BRILLIANT TUTORIALS! I've always wanted to start learning PICO-8, and now I can!
I'm having trouble with the draw_player function and it's showing an error saying that the "P" variable is a nil value whenever I run the game, I'm sure I put in your script exactly as it shows in your video can you help me fix this?
So well explained. Thank you so much.
Thank you so much for making these videos! They are top notch!
Good stuff. Time for step 3
2:49 wait what in the middle of x and 8🤨?
A thought, for the map co-ordinates to pixel co-ordinates conversion, you could pre-calculate them and then use a lookup table, using the map co-ordinate as the key and the pixel co-ordinate as the value.
Also I honestly like how you described the braces for creating an object as "A big hug", I've honestly never thought about it that way but I like it.
Subscribed!
Why use a period for the variables? "pkey" seems functionally the same as "p.key", but only uses only one token, instead of two.
how do you do that thing at SPR(P.SPRITE,P.X,?8,P.X?8)
That's an asterisk! A * symbol. (Shift-8 on your keyboard.) That symbol is used for multiplication in coding. Hope that helps! :)
@@DylanBennett thank You so much man😁
My characters Y value isnt changing when i change the p.y value in the make player function nor can i move it up or down when i follow the next tutorial. any help?
what if my player is bigger than just one tile? if it is 2x2 i mean.. how do i type that out instead? or where can i find that information? thank you and great video
when ever i do ctrl+r to run it takes me to the help menu. help me please
try entering the command run instead (esc then type in run)
Great tutorial! Subbed!
my player is 4 tiles big, how do I draw a 4 tiled sprite onto the map?
you can actually just use the name of the sprite, so spr(coin, 10, 10) will work too
Is every variable global? Even it is inside a function?
Yes. If you want a variable to have limited scope, put "local" in front of it. That is how Lua works, which is the language PICO-8 uses.
this doesn’t work for my version
i'm a bit late but my player won't show up :(
A couple things to make sure of are that your draw_player() function is _after_ your draw_map() function, and then also make sure that your p.sprite variable points to the sprite number where you made your player sprite. In my example, I drew my player using sprite 1, so I set p.sprite to 1. But if your player sprite is on, say, sprite 5, then you would need to set p.sprite to the number 5. If that still doesn't work, let me know.
Im even later, but I’m having the same problem, my draw_player is under my draw_map and the player sprite number is entered correctly so I have no idea what to do next.
@@MontgomeryHanandCo same
I have 'runtime error line 13 tae 0
draw_map ()
Attempt to call global 'global_map' (a nil value)*
Usually that error means there's a typo in the name of either the draw_map() function on Tab 1, or where you tell it to run the draw_map() function in the _draw() function on Tab 0. Feel free to copy/paste your Tab 1 and Tab 0 code here into a reply if you take a look and don't see anything wrong.
@@DylanBennett
Tab 0
"--gameloop
--runs one time
function _inite()
map_setup()
make_player()
end
--runs again and again every 30 sec
function _updates()
end
--runs as _updates, but only after it.
function _draw()
cls()
draw_map()
draw_player()
end"
Tab1
"--map
function map_setup
--map tile settings
wall=0
key=1
door=2
anim1=3
anim2=4
lose=6
win=7
end
function draw_map()
map(0,0,0,0,128,64)
end"
@@rbernhardsson9857 I see a few things to fix! All of them are small, but they will really throw a monkey wrench into things. First, you have an extra "e" on your _init() function name. (Should be "_init()" instead of "_inite()".) Second, there's an extra "s" in your _update() function name. (Should be "_update()" instead of "_updates()".) Lastly, you need to make sure to add the parentheses to the end of your map_setup() function. Right now it says, "function map_setup", but it should say, "function map_setup()". I hope that helps! If you are still running into issues, please let me know. Don't get frustrated over little typos like that either. Little things like that are easy to miss and super common (even for programmers that have been programming for literally decades).
@@DylanBennett Thanks, it did the job
thx
Perfect #aangyosa #polmess ❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️ from INDONESIAN
You should be a computer teacher in school 😊
I CAN'T DO THIS! It's a nil value apparently, whatever THAT means. P is not a global variable apparently! I don't know what I'm doing wrong!
I'd be happy to help if I can. Can you post the code you have put in already for tabs 0 and 2? Also, make sure you are running make_player() in your _init() function in tab 0. And then also make sure draw_player() is in the _draw() function.
@@DylanBennett
This is in Tab 0:
--game loop
function _int()
make_player()
map_setup()
end
function _update()
end
function _draw()
cls()
draw_map()
draw_player()
end
This is in Tab 2:
--player code
function make_player()
p={}
p.x=3
p.y=2
p.sprite=16
p.keys=0
end
function draw_player()
spr(p.sprite, p.x*8, p.y*8)
end
@@cheshirecreeper3743 one small typo! You have "int" instead of "init”, so it's never actually running that function.
@@DylanBennett Getting the same error, no typo, my code:
TAB 0:
function init()
map_init()
player_init()
end
function _update()
end
function _draw()
cls()
draw_map()
draw_player()
end
TAB 2:
function player_init()
p={}
p.x=3
p.y=2
p.sprite=64
end
function draw_player()
spr(p.sprite,p.x*8,p.y*8)
end
EDIT: OOPS! map_init and player_init round the wrong way !
EDIT2: Still doesn't work...
@@lounowell4171 Just one little missing character! The first function is supposed to be _init() but it looks like you have just init() instead. (Not the missing _ character.)