Hello, i have this function for returning the int from dictionary
var venue_list : Dictionary = {}
func get_venue_state(venue_id: int) -> int:
# Check if the id exists in the dictionary directly
print("Checking venue_id:", venue_id)
print("Current venue_list keys:", venue_list.keys())
if venue_id in venue_list:
print("id exists in the dictionary")
return venue_list[venue_id]
# If not, set the venue state to LOCKED
return STATE.LOCKED
When I called it with venue_id 10, it literally has a value of 10 in the venue_list. But why doesn’t it print “ID exists in the dictionary”?
.has() is same as in as per docs… Will not work if you have incompatible key types.
As far as how you fill out Dictionaries, there are many ways. Study the Dictionary class.
STATE.LOCKED is probably an enum. Where did you find it?