Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I want to iterate through the levels of my floor storage. For now, I just want to know if the slot in the level is used (an item is placed here) or not. The FloorStorage has 1 Bay, 10 Levels and 1 Slot per level.
Problem: I tried to write a simple for-loop to address this issue. My current approch looks like this:
Storage.Object storage = Model.find("FloorStorage");
for (int levelNum = 1; levelNum <= 10; levelNum++) {
// Access the slot in the first bay (Bay 1) at the current level
Storage.Slot test = storage.getSlot(1, levelNum, 1);
// Check if the slot is occupied
if (test.items.length > 0) {
print("Level", levelNum, "is used. Item:", test.items[1].name);
} else {
print("Level", levelNum, "is EMPTY.");
}
}
Everytime I execute this code, I receive the following error message which I can't fix right now with my beginner's knowledge:
time: 1.000000 exception: FlexScript exception: Invalid access to a Storage.Slot label that does not exist at MODEL:/FloorStorage>variables/onSlotEntry at line 0
Solved! Go to Solution.