Upbge: Issue with "for key, input in sensor.inputs"

Created on 31 Mar 2020  Â·  17Comments  Â·  Source: UPBGE/upbge

Hello,

I found something wrong with this code: "for key, input in sensor.inputs". Python return this: "TypeError: 'int' object is not iterable".

But this code is written like that in the wiki. The old "for key, input in sensor.events" work perfectly but i have this warning message:

"Warning: my_script(line_code), method sensor.events is deprecated, please use sensor.inputs instead."

Is there a bug or human mistake ?

Most helpful comment

inactive, active, activated and released properties were just recovered in last build.

All 17 comments

i'm trying to reproduce the error

import bge
own = bge.logic.getCurrentController().owner
for key, input in own.sensors["Keyboard"].events :
print(key,input)

image

no error return with my code.

the alert is caused by an old method or property that is no longer supported by the system

Hello RomStef,

In the wiki of upBGE the new method is for key, input in sensor.inputs
In the wiki of BGE 2.79 for key, input in sensor.events

It is the new method who wrong.

if you use bge.logic.keyboard.inputs[bge.events.SOMEKEY] or sensor.inputs[bge.events.SOMEKEY] you can test directly the properties : Active , Inactive , Activated and Released.

http://shuvit.org/python_api/bge.types.SCA_InputEvent.html#SCA_InputEvent

i suggest you to print the class method and properties to screen and dig into the problems you want to solve.

my method to detect the keypress is for example :

if bge.logic.keyboard.inputs[bge.events.WKEY].active :
-> move forward

for key, input in sensor.events works. So why who is the charge of the improvement about the python part of the upBGE change the method for the new version if this method doesn't work ?

Between, somebody can tell me what the status of the improvement of the upBGE ? The last information i have is the team in charge is broken, it's correct ?

I can't solve the problem myself, i don't have enough knowledge to play with source code. I don't know how to compile or decompile it anyway.

I just want to report the problem to help much i can. Stay in version 2.79 from the BlendFoundation is the same for me, you know.

@youle31 and @lordloki still works on upBGE and ported it in blender 2.8 as upBGE 0.3.0 Alpha. I don't know why the keybord sensor method changed but it works for me without errors. maybe if you can post an example file i can try to help you

from bge import logic as gl
from bge import events as ev

scene = gl.getCurrentScene()
obj = gl.getCurrentController().owner

for key, statut in obj.sensors['chx_key'].events: # here, i should replace with input but the error is here for python
if statut == gl.KX_INPUT_JUST_ACTIVATED:
if key== ev.ENTERKEY:
obj['assign'] =
var_player['name'] = obj['give_name']
obj['give_name'] =

             elif key == ev.BACKSPACEKEY:
                    obj['give_name'] = obj['give_name'][:obj['limit_char_nam'] - 1]
                    obj['limit_char_nam'] -= 1
                    gl.text_main[0].text = obj['give_name']

             elif key == ev.RIGHTSHIFTKEY or key == ev.LEFTSHIFTKEY:
                    obj['shift'] = True

i have found some issue but this code should work

image

image

@youle31 @lordloki I have encountered some problems with the SCA_InputEvent class.

inactive, active, activated and released properties no longer exist.
bge.events.ENTERKEY no longer exists.

maybe the code is misaligned compared to version 2.4b

upbge 0.3 is based on an "old" version of upbge (this is based on a version between 0.1.7 and 0.1.8 iirc). The code has changed slightly concerning events after 0.1.8, then what you can look in the 0.2.4 API is not necessarly in upbge 0.3 which had a slightly different system.
I'll add a mention on the "development ideas" thread to see if we can recover commits related to events after 0.1.8

I upload a tesfile i just did to see how are working events (because even if there's a warning message, I often use the old system):

https://pasteall.org/blend/fc9e4cbe5faa4dbab149724e3d08364d

I'd like to precise the error i see it was on the 0.2.3 version upBGE. The code RomStef has written should be logic about the "int" input profile.

Nobody has try to make a game or a "special" blend with the new upBGE items to verify them ?

inactive, active, activated and released properties were just recovered in last build.

The 0.2.4b ? It is more stable and reliable now ?

No, i was referring to last upbge 0.3 alpha build

Oh, i understand. This is for EEVEE engine, right ?

I need actually something reliable for building my game and i'm not yet ready to use the node system with EEVEE, i have so much to learn from the BGE itself, even if i have a modest global level now about it.

But, if i can do something to test python feature part...

Indeed the API for sensor.inputs seem false and sensors.inputs only return an integer (idk for keyboard.inputs). But the API is hosted by shuvit and I don't know if we'll recompile it.
As it's a minor issue, I close this task.

yeah I used this today

swapped from event[0] to event

On Wed, Apr 15, 2020 at 7:54 PM youle31 notifications@github.com wrote:

Closed #1162 https://github.com/UPBGE/upbge/issues/1162.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/UPBGE/upbge/issues/1162#event-3237985983, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ABW3SWILXJYADWHJQKDNL5TRMZXNZANCNFSM4LXPCG6Q
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IzaZed picture IzaZed  Â·  6Comments

denicolas picture denicolas  Â·  4Comments

vlad0337187 picture vlad0337187  Â·  7Comments

IzaZed picture IzaZed  Â·  6Comments

RomStef picture RomStef  Â·  7Comments