Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | CilantroMC |
I am trying to simply get a value from an array on another script. I am very familiar with other programming languages and have used Python in the past, so this isn’t too new to me, however, at Godot I am a beginner.
First Script:
var storeSlots = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1];
Second Script:
export (int) var storeSlotID;
var storeID;
func _process (delta):
# Get the storeID from the store slot.
storeID = get_node("../../Level Generator").storeSlots[storeSlotID];
I am continually getting the error "Invalid Get Index ‘0’ (On Base: Array). This seems like an extremely simple task and I have debugged endlessly to no avail. I am utterly confused at what is happening so any help is much appreciated.
The first time I tried it I got an “invalid index NULL on base: array” but after setting it to 0 in the editor, it works fine. scene hierarchy:
scene_root
-Level Generator (first script)
-something
--something_else (second script)
You’ll have to add more information about what you’re doing / upload a sample project somewhere.
markopolo | 2018-04-08 19:12