PyBoyP
PyBoy9mo ago
MorganPG

How can I access PyBoy.mb from within a subclass.

This has probably been asked before but I wanted to try to get local link support working in PyBoy
I felt it would be easier to modify if I made it a subclass of PyBoy.

Here is a small snippet of my code:
class LinkBoy(PyBoy, LinkDevice):
  def RecievedFullByte(self):
        self.memory[0xFF02] = clearBit(self.memory[0xFF02], 7)
        self.mb.cpu.set_interruptflag(0b00001000)


When data is transmitted I get this error:
Traceback (most recent call last):
  File "e:\LinkBoy\main.py", line 9, in <module>
    link.step()
  File "e:\LinkBoy\linkboy.py", line 75, in step
    transfer.step()
  File "e:\LinkBoy\linkboy.py", line 56, in step
    self.slave.RecievedFullByte() #Notify the slave device the transfer has completed
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "e:\LinkBoy\linkboy.py", line 109, in RecievedFullByte
    self.mb.cpu.set_interruptflag(0b00001000)
    ^^^^^^^
AttributeError: 'LinkBoy' object has no attribute 'mb'


Is there any way to get around this withot directly modifying the library, or do i have to do that?
Was this page helpful?