0 votes

Basically, i have a singleton to keep track of the stock of a number of items, it looks like this:

var item0 = 6
var item1 = 3
var item2 = 8

you get the idea.

What i want is to be able to access those variables, using a variable in another node. For example:

var take_item = item2

Stock.take_item -= 1

This, of course, doesnt work because "take_item" is not a variable on the "Stock" singleton, so how can i "translate" between the two?

Thanks in advance!

Godot version 3.3 Stable
in Engine by (309 points)

1 Answer

0 votes
Best answer

Found the solution:


works perfectly!

by (309 points)
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 Frequently asked questions and 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 [email protected] with your username.