str() Function android problem

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By menza
:warning: Old Version Published before Godot 3 was released.

Hello,

When I tried this code ;

get_node(“Label”).set_text(str(number))

It was not working in android But after I have changed code, like this;

get_node(“Label”).set_text(“aa”)

It’s work fine. So my problem probably arise from str() function. Ok I find some information and They told “Installing the newest export templates fixed it.” I know after export newest templates work fine but I have compiled admob and play game services modules for android so I need to use them for project.

What Labels and what did you expect?
Any error messages while compiling android template?
Any logs on adb logcat?

volzhs | 2016-07-27 14:38

Hello, I have found problem. When I tried this code;

get_node("Label").set_text(str(number))

It was not working But after I have changed code, like this;

get_node("Label").set_text("aa")

It’s work fine. So my problem probably arise from str() function.

menza | 2016-07-27 16:54

:bust_in_silhouette: Reply From: jospic

str(): it seems that this function does not exists in GDScript…
Instead you must use:

 get_node("Label").set_text(var2str( number ))

It does exist, and works: @GDScript — Godot Engine (latest) documentation in English

Akien | 2016-07-28 10:09

Hello, I get this;

I/godot   ( 4868): e[1;35mSCRIPT ERROR: random: e[0me[1mInvalid type in function 'set_text' in base 'Label'. Cannot convert argument 1 from bool to String.

I/godot ( 4868): e[0;35m At: res://scenes/Questions.gdc:123.e[0m

in logcat .what I am use str() or var2str() from each function.

menza | 2016-07-28 14:53

Probably, your function argument is a boolean, it must be a number…

jospic | 2016-07-28 15:08

str() can convert booleans and numbers alike, so that’s not the problem.

Akien | 2016-07-28 15:10

I am sure my variable integer.

menza | 2016-07-28 15:11

:bust_in_silhouette: Reply From: Akien

As you mentioned, it works fine with up to date export templates, so you need to rebuild yours if you need custom modules.

str() function work fine with this templates but not work after compile new templates without new modules or with.

menza | 2016-07-28 14:57

If you build templates using the source code from the master branch, but try to use them in Godot 2.0.4.1, it won’t work. You need to have templates that match your editor version.

Akien | 2016-07-28 15:00

Godot version Godot v2.0.4.1 but still don’t work.

menza | 2016-07-28 15:13

I have tried it with Godot Engine 2.1-rc1 and its work fine but this new templates compiled without my modules so I will add new modules and compile android again.

EDIT:Also everything work fine after using templates with Godot Engine 2.1-rc1. Thanks for helps @Akien . So my problem arise from versions.If anyone try to add new modules and compile for new template from Latest source code you need to use unstable version godot engine.

menza | 2016-07-28 15:19