Question about coding diferences in different projects

confused

#1

I am trying to transfer the code of my recently published snap-grid project onto my Hopscotch in Hopscotch project. The code is completely identical in both projects, but it isn’t working. The object snaps to the grid, but can’t be taken off it. Am I doing something wrong? I have triple checked the maths, and it is identical. Thanks.


#2

If 2 similar sets of code aren’t working exactly the same, then the codes aren’t identical. Keep looking.

Here’s a few things you could check:

  • Check all the object reference bubbles to make sure they’re the same. This is a common error when copying code.

  • Make sure there’s not a conflict with variables of the same name being used elsewhere in the project you’re copying the code to.

  • Depending on the code, the order of objects & the order of rules with each object may be important.


#3

Something in the code of the project you’re adding the snap-grid code to may be making it do that or something…


#4

Weird. I would check that all nested blocks are correctly placed and that you haven’t made some small mistake somewhere. I spent a little bit less than an hour once trying to figure out why my code wasn’t working (in Python). Then, I even asked my question online, and all I did was a spelling mistake in one place in my code (on the name of a variable).


#5

I can sympathize. I once spent hours, plural, trying to help a Computer Science major student/friend find the bug in her Fortran code (after she herself had already spend hours trying to debug it). Turns out that she had typed one of the line numbers using a capital O (e.g. 14O) instead of a zero (e.g. 140), but it wasn’t obvious in the font Fortran used :confounded::upside_down_face:


#6

Thx for the help… The screenshots I took of the original code that I was useing were faulty… Whoops. :disappointed:


#7

I can can certainly sympathize too… I spent hours poring over the code double and triple checking the screenshots I took. Sigh… Thanks again.


#8

Glad you found the problem :+1: