Script Works locally in Emulator but not on Hardware

I wrote a mode using CS Code and the Eyesy emulator. Everything works fine but when I load it on hardware and try to run it seems to not be able to load the necessary libraries. Specifically pygame.math.vector2

There are also some other oddities like when I used basic sys commands like type() are not running on the eyesy but do in the emulator on VS code.

The following code produces the subsequent print statement in the Eyesy console for example:

try:
        print("----------result type: " + str(type(vectorToLimit)))

image\

whereas in the VScode environment it outputs as expected

image

Any Ideas? Ive attached the script below. Code is a mess. In the words of the great Daniel Shiffman… “I will refactor this later.”

main.py (14.0 KB)

which version of Pygame do you have installed on your computer?

Pygame version 2.1.2
image

What version is running on the Eyesy? could it be that version doesnt have a vector2 object? If so can I update Pygame on the Eyesy?

I cant even get a basic scritpo to test Vector2 object to run.

import pygame
import random
from pygame.locals import *
import pygame.gfxdraw
import math

testVector  = pygame.Vector2(2,3)

def setup(screen, etc) :
    pass

def draw(screen, etc) :
    print(str(testVector))
   

This running on the Eyesy spits out

Mode ZHS - Boids not loaded, probably has errors.
Starting
error with setup: Traceback (most recent call last):
  File "main.py", line 188, in 
    mode.setup(screen, etc)
  File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 12, in setup
    def draw(screen, etc) :
AttributeError: 'module' object has no attribute 'Vector2'

error with draw: Traceback (most recent call last):
  File "main.py", line 195, in 
    mode.draw(screen, etc)
  File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 18, in draw
NameError: global name 'testVector' is not defined

This same exact code running locally produces the expected output in the console.

PS E:\Eyesy\Scripts\Boids> eyesim --mode-folder "E:\Eyesy\Scripts\Boids"
pygame 2.1.2 (SDL 2.0.18, Python 3.6.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
********************************************************************************
Press the spacebar to toggle widget visibility!
********************************************************************************
[2, 3]
[2, 3]
[2, 3]
[2, 3]
[2, 3]

It might be a version problem. I think the most recent EYESY OS is using Pygame v1.9.2 or 1.9.3 (although looking at the docs vector2 should be available in 1.9.3…so might be something else)

Ugh I dont want to have to write all the vector math methods… You think I could get that class from pygame and include it as a local import? Im trying to find out if I can just copy paste that into my code.

Looking into that possibility it seems like the better solution is to figure out how to get pygame.math.Vector2 working. Any help is more than appreciated. I promise to pay it back with cool modes…

2 Likes

Smart people, assemble!

Ive already got about 90% of my own vector class working. but it would be good to know what the issue is anyway. Basically just a few geometry and arithmetic features. Again though this is working locally but giving me issues on hardware :sob:

Ive attached the full file for anyone who wants to take a look. Now the issue is that operator functionality isnt working on hardware…

error with draw: Traceback (most recent call last):
  File "main.py", line 195, in 
    mode.draw(screen, etc)
  File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 114, in draw
    b.flock()
  File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 304, in flock
    alignment = self.align(nearBoids)
  File "/sdcard/Modes/Python/ZHS - Boids//main.py", line 355, in align
    steering /= total
TypeError: unsupported operand type(s) for /=: 'instance' and 'int'

This works fine in the emulator…

main.py (15.2 KB)

The type error looks like an issue with eyesy running python 2. This seems to confirm specifically with the deviding feature. Making progress.

eyesim · PyPI

Got it working with my own vector class and swapping out itruediv for ifloordiv in the aritmetic functions. Now I just have to optimize. Lesson learned. Python 2 on the eyesy vs Python 3 in the emulator

I made a script that also only works in the emulator and not the eyesy itself. I have no idea why since it’s a relatively simple file too.

I replied to your post. I think I resolved your issue.