0 votes

Good day!
There is a problem when exporting to android.
If script export mode is compiled - error!
If script export mode is text - it works!

log cat:

04-24 03:32:42.568 28146 28161 I godot   : free current scene
04-24 03:32:42.572 28146 28161 I godot   : free background
04-24 03:32:42.572 28146 28161 I godot   : Background load scene...
04-24 03:32:42.572 28146 28161 E godot   : **SCRIPT ERROR**: Invalid type in built-in function 'range'. Cannot convert argument 1 from String to float.
04-24 03:32:42.572 28146 28161 E godot   :    At: res://Scripts/CoreSceneManager.gdc:31:AS_SceneManager._init_bg() - Invalid type in built-in function 'range'. Cannot convert argument 1 from String to float.

Where did this function 'range' come from ?!

AS_SceneManager - is singleton:

func _init_bg() -> void:

    printerr("free current scene")
    if current_scene != null :
        current_scene.free()
        current_scene = null

    printerr("free background")
    if background_scene != null :
        background_scene.free()
        background_scene = null

    printerr("Background load scene...")
    var res_bg = ResourceLoader.load(background_tscn, "", false)  # <<<==== ERROR! Line 31 WHAT?!
    printerr("Background load success")
    background_scene = res_bg.instance()
    printerr("Background instance")
    get_tree().get_root().add_child(background_scene)
    get_tree().set_current_scene(background_scene)
    background_scene.init_bg()
    goto_scene("res://Scenes/Loading.tscn")
    return

Background tscn:

func init_bg() -> void :
    if not get_viewport().is_connected("size_changed", self, "_on_size_changed"):
        #warning-ignore:return_value_discarded
        get_viewport().connect("size_changed", self, "_on_size_changed")

    _on_size_changed()
    if has_node("AnimationPlayer") :
        $AnimationPlayer.play("Run")

    return

func _on_size_changed() -> void:
    #... change size Node2D scene...
in Engine by (35 points)

Did you use range() in a class inheriting CoreSceneManager.gd?
If not... that would be a bug. If you can reproduce this in a minimal project you should report it on Github.

Only in this function. Analogue of the existing function "print_tree".
But it outputs to a variable tree.
Called in a special error scene.

func get_node_tree_name(node : Node, var indent : String = "", var last : bool = true) :
if node == null :
    return ""

str_buffer += indent + "|\n"
str_buffer += indent

if last :
    str_buffer += "\\--"
    indent += " "
else :
    str_buffer += "|--"
    indent += "|  "

str_buffer += node.name + "\n"

var childs =  node.get_children()

for i in range(childs.size()) :
    get_node_tree_name(childs[i], indent, i == (childs.size() - 1))

What version are you using? I think this should be fixed in recent versions.
https://github.com/godotengine/godot/issues/25334

3.1 stable verison used

I redid the code.
This script is executed in the scene (Background).

extends Sprite

export(float) var time_offset = 0.0
const _multi_rect : float = 3.0
const _min_size : float = 2048.0
const _half : float = 0.5
const _speed_k : float = 0.005
const _step_offset : float = 128.0

var time : float = 0.0
func _ready():

    time = time_offset
    var viweport = get_viewport()
    if viweport != null :
        viweport.connect("size_changed", self, "_update_rect")
        _update_rect()


func _update_rect() :
    var viweport = get_viewport()

    printerr("set x")
    var x : float = max(_min_size, viweport.size.x * _multi_rect)
    printerr("set y")
    var y : float =  max(_min_size, viweport.size.y * _multi_rect)

    printerr("set sprite size")
    self.region_rect.size = Vector2(x, y)
    printerr("set bg sprite position")
    self.global_position = Vector2(viweport.size.x * _half, viweport.size.y * _half) 
    self.position.x += _step_offset * time_offset
    self.position.y += _step_offset * time_offset


func _process(delta):
    time += (delta * _speed_k)
    self.position.x += sin(time) * _half
    self.position.y += cos(time) * _half

If you remove the script - WORK! ...

ERROR:

04-25 00:16:32.100 32445 32460 E godot   : **SCRIPT ERROR**: Parse Error: Too few arguments for 'wrapf()' call. Expected at least 3.
04-25 00:16:32.100 32445 32460 E godot   :    At: res://Scripts/SpriteBackground.gdc:28:GDScript::load_byte_code() - Parse Error: Too few arguments for 'wrapf()' call. Expected at least 3.
04-25 00:16:32.100 32445 32460 E godot   : **ERROR**: Method/Function Failed, returning: ERR_PARSE_ERROR
04-25 00:16:32.100 32445 32460 E godot   :    At: modules\gdscript\gdscript.cpp:785:load_byte_code() - Method/Function Failed, returning: ERR_PARSE_ERROR
04-25 00:16:32.101 32445 32460 E godot   : **ERROR**: Condition ' err != OK ' is true. returned: RES()
04-25 00:16:32.103 32445 32460 E godot   :    At: modules\gdscript\gdscript.cpp:2173:load() - Condition ' err != OK ' is true. returned: RES()
04-25 00:16:32.103 32445 32460 E godot   : **ERROR**: Failed loading resource: res://Scripts/SpriteBackground.gdc
04-25 00:16:32.103 32445 32460 E godot   :    At: core\io\resource_loader.cpp:285:_load() - Method/Function Failed, returning: RES()

1 Answer

0 votes

My mistake!
I made the export template on the "master" branch, not "3.1-stable"

by (35 points)

Yeah, I've done this mistake myself quite a lot of times, have to keep export templates in sync :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.