Godot: Iterating over a range() on android has weird behaviour

Created on 7 Nov 2018  路  4Comments  路  Source: godotengine/godot

Godot version: c8700f83a1832a6c9b809af17ce67f5f0ba2ef32

OS/device including version: Android 6.0

Issue description:
Examine the following gdscript:

for i in range(5) :
    print(i)

One would expect to log the numbers 0-4 in console. While this works on Windows, on Android I get the following:

11-07 13:37:15.736  9633  9646 I godot   : 2
11-07 13:37:15.736  9633  9646 I godot   : 0
11-07 13:37:15.736  9633  9646 I godot   : 0
11-07 13:37:15.736  9633  9646 I godot   : 0
11-07 13:37:15.736  9633  9646 I godot   : 5
11-07 13:37:15.736  9633  9646 I godot   : 0
11-07 13:37:15.736  9633  9646 I godot   : 0
11-07 13:37:15.736  9633  9646 I godot   : 0

Which is very strange and incorrect.

Steps to reproduce:

Use range() in a for loop

Minimal reproduction project:

New Game Project.zip

bug android core

Most helpful comment

I can work around the issue just fine using Vector2(0, 5) instead of range(5). I feel like it would be better to fix gdscript.

All 4 comments

Try something like this maybe, I still have not seen the code yet but this might help.

def frange(start, stop, step):
i = start
while i < stop:
yield i
i += step

for i in frange(0, 4):
print(i)

I can work around the issue just fine using Vector2(0, 5) instead of range(5). I feel like it would be better to fix gdscript.

Is this still reproducible in the current master branch or latest beta build?

Tested with 8889089c1b on a Samsung Galaxy S3, can't reproduce the bug.

It was either fixed in the meantime, or maybe you were actually using Android templates that don't match your editor version (I can see you had custom templates in your export preset).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blurymind picture blurymind  路  3Comments

SleepProgger picture SleepProgger  路  3Comments

EdwardAngeles picture EdwardAngeles  路  3Comments

n-pigeon picture n-pigeon  路  3Comments

Spooner picture Spooner  路  3Comments