Topic: SmoothEventReciever - error when key pressed

Im using the latest addons.zip 2008 06 09 with irrlicht 1.5.1. and Blitzmax 1.34. I get an error when I press any key ."Unhandled Exception:Attempt to index array element beyond array length.

on 5th line of OnEvent Method

' push the key
            m_char_buf = m_char_buf[..m_char_buf.Dimensions()[0] + 1]  <- here!!
            m_char_buf[m_char_buf.Dimensions()[0] - 1] = key
        
            m_key_buf_old[key] = m_key_buf[key]
            m_key_buf[key] = event.getKeyPressedDown()

I created the receiver with:-

Receiver:SmoothEventReceiver = SmoothEventReceiver.createReceiver()
device.setEventReceiver(Receiver)

Re: SmoothEventReciever - error when key pressed

greetings smile  my apologies on the response delay.  unfortunately i am unable to replicate this issue.  here is a modified hello world that prints keys pressed using the SmoothEventReceiver.  please give it a whirl and see if you get the issue here as well.  also, what version of BMAX are your running?  what OS?  we may need to rebuild mods.

SuperStrict
Framework Irrlicht.Core
Import Irrlicht.AddOns

?MacOS
Local device:IrrlichtDevice = ..
    IrrlichtDevice.Create(EDT_OPENGL, _DIMENSION2DI(640, 480), 16, ..
        False, False, False, Null)
?Not MacOS
Local device:IrrlichtDevice = ..
    IrrlichtDevice.Create(EDT_BURNINGVIDEO, _DIMENSION2DI(640, 480), 16, ..
        False, False, False, Null)
?

If Not device Then Return
        
device.setWindowCaption("Hello World! - Irrlicht Engine Demo")

Local Receiver:SmoothEventReceiver = SmoothEventReceiver.createReceiver()
device.setEventReceiver(Receiver)

Local driver:IVideoDriver = device.getVideoDriver()
Local smgr:ISceneManager = device.getSceneManager()
Local guienv:IGUIEnvironment = device.getGUIEnvironment()

guienv.addStaticText("Hello World! This is the Irrlicht Software renderer!", ..
    _RECTI(10,10,260,22), True)
    
Local mesh:IAnimatedMesh = smgr.getMesh("../../media/sydney.md2")
If Not mesh Then Return
Local node:IAnimatedMeshSceneNode = smgr.addAnimatedMeshSceneNode( mesh )

If node
    node.setMaterialFlag(EMF_LIGHTING, False)
    node.setMD2AnimationFromType ( EMAT_STAND )
    node.setMaterialTexture( 0, driver.getTexture("../../media/sydney.bmp") )
EndIf

smgr.addCameraSceneNode(Null, _VECTOR3DF(0,30,-40), _VECTOR3DF(0,5,0))

While device.run() 

    driver.beginScene(True, True, _SCOLOR(255,100,101,140))

    smgr.drawAll()
    guienv.drawAll()

    Local key:Int = Receiver.popkey()
    Print key

    driver.endScene()
EndWhile

device.drop()

Re: SmoothEventReciever - error when key pressed

Re: SmoothEventReciever - error when key pressed

...
m_char_buf = m_char_buf[..m_char_buf.Dimensions()[0] + 1] 
m_char_buf[m_char_buf.Dimensions()[0] - 1] = key

m_key_buf_old[key] = m_key_buf[key]
m_key_buf[key] = event.getKeyPressedDown()
...

Re: SmoothEventReciever - error when key pressed

Re: SmoothEventReciever - error when key pressed

there is a new version of the addons for download.