Unable to assign variables with sprite values

Help and questions on programming the codebug
Post Reply
nwholloway
Posts: 2
Joined: Wed Dec 16, 2015 9:59 pm

Unable to assign variables with sprite values

Post by nwholloway » Wed Dec 16, 2015 10:50 pm

I found that when I went to download the compiled code for something I was working on, that the compilation failed.

Through a process of elimination, I found the problem was assigning a variable from another that contains a sprite.

This fragment demonstrates the problem.

Code: Select all

a = sprite_build([[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]);
b = a;
The project is http://www.codebug.org.uk/explore/codeb ... ssignment/.

mikerr
Posts: 83
Joined: Fri Jul 31, 2015 10:37 am
Contact:

Re: Unable to assign variables with sprite values

Post by mikerr » Thu Dec 17, 2015 12:31 pm

I've seen this one before - uninitialised sprite variable,
a workaround is to initialise the variable with a sprite first, and the getcharactersprite uses the least screen space for that:

Image
Twitter @mikered codebug profile mikerr

nwholloway
Posts: 2
Joined: Wed Dec 16, 2015 9:59 pm

Re: Unable to assign variables with sprite values

Post by nwholloway » Fri Dec 18, 2015 10:05 pm

That's a good workaround.

Post Reply