Android: values are null in one Script

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

On android I get strange errors:

I/godot   ( 1575): SCRIPT ERROR: _process: Invalid operands 'Nil' and 'int' in operator '+'.
I/godot   ( 1575):    At: res://scripts/hero.gdc:75.

And other errors which are caused by hero.gd because everything is nil.
On Windows everything works fine!!

Here is a part of the hero.gd:

extends KinematicBody2D


var dir = "RIGHT"
var lefttexture = load('res://sprites/hero_M_Left.tex')
var righttexture = load('res://sprites/hero_M_Right.tex')
export var WALK_SPEED = 200.0
export var GRAVITY = 200.0
export var JUMP_HEIGHT = 200.0
export var DAMAGE_MULTIPLIER = 1.0
export var ATTACKSPEED_MULTIPLIER = 1.0
export var LEVEL = 1
var velocity = Vector2()
var scale = Vector2()
var left = false
var right = false
var up = false
var attack = false
var attacking = false
var isPressed = false
onready var sprite = Sprite
onready var upbutton = TouchScreenButton
onready var leftbutton = TouchScreenButton
onready var rightbutton = TouchScreenButton
onready var JumpingArea = Area2D
onready var level_Label = RichTextLabel
onready var Spit = RigidBody2D
onready var SpitArea = Area2D
var jumping = false
var temp_Health_regen = 0
var Health = 100
var max_Health = 100
var experience = 0
var max_Experience = 10
var regeneration = 0.01
var hitting = false
var hitting_Damage = 0
var canSpit = true
var timer = 0
var damagetimer = 0
var canBeDamaged = true

func respawn():
	self.set_pos(Vector2(300, 291))
	jumping = false
	Health = max_Health
	attack = false
	attacking = false
func _on_Area2D_body_enter( body ):
	print("Entered Area2D with body ", body)
func _on_Area2D_body_exit( body ):
	print("Exited Area2D with body ", body)

func _ready():
	
	self.set_meta("hero", true)
	sprite = get_node("/root/Node/Node/Hero/HeroTexture")
	upbutton = get_node("/root/Node/CanvasLayer/Control/Up")
	leftbutton = get_node("/root/Node/CanvasLayer/Control 2/Left")
	rightbutton = get_node("/root/Node/CanvasLayer/Control 3/Right")
	JumpingArea = get_node("/root/Node/Node/Hero/JumpingArea")
	Spit = get_node("/root/Node/Node/Spit")
	SpitArea = get_node("/root/Node/Node/Spit/spitarea")
	level_Label = get_node("/root/Node/CanvasLayer/Control 4/Level_Container/Level_Label")
	
	JumpingArea.connect("body_enter",self,"_on_Area2D_body_enter")
	JumpingArea.connect("body_exit",self,"_on_Area2D_body_exit")
	
	level_Label.update_Level(str(LEVEL))
	spittingtimer()
	set_process(true)
func _process(delta):
	timer = timer+1
	if(timer >= 60 ): #THIS IS LINE 75
		spittingtimer()
		timer = 0
	if(canBeDamaged == false):
		print("timer")
		damagetimer = damagetimer+1
		if(damagetimer >= 20):
			canBeDamaged = true
			damagetimer = 0
	if(experience >= max_Experience):
		experience = 0
		LEVEL = LEVEL+1
		max_Experience = max_Experience*(LEVEL/1.75)
		level_Label.update_Level(str(LEVEL))
	if(Health < max_Health):
		temp_Health_regen = temp_Health_regen+regeneration
	if(temp_Health_regen >= 1):
		Health = Health+temp_Health_regen
		temp_Health_regen = 0
	if(self.get_pos().y >=1000):
		respawn()
	if(Health <= 0):
		respawn()
	if(OS.get_name() == "Android"):
		process_Android(delta)
	else:
		process_Windows(delta)

Why do I get this error? I mean timer isn’t null:

var timer = 0

I’m using the latest nightly of the Engine (2.1 alpha)

does the error come up at start?
isn’t hero dead?

volzhs | 2016-06-25 14:58

The error comes up at start and always continously spams the logcat console. The hero is not dead. Because it’s null I can’t even move him. Variables like ‘dir’ are not null.
It happens only in hero.gd. Other scripts like the enemy script are working.

AlGrande | 2016-06-25 15:49

That sounds weird.
But I can’t guess what the problem is without testing myself.
Can you make a sample project can reproduce this?

volzhs | 2016-06-25 16:07

I can’t reproduce it. Can I pm you the link somewhere?

AlGrande | 2016-06-25 17:18

volzhs at gmail.com

volzhs | 2016-06-25 19:15

:bust_in_silhouette: Reply From: AlGrande

Okay this is very strange but I solved the problem: I created a new project and I copied all files from the old project into the new project. I think I got the problem because I upgraded from the release to the alpha version.

good to hear. :slight_smile:

volzhs | 2016-06-26 15:42