Godot Version
v4.5.stable.official [876b29033]
(was v4.3.stable.official [77dcf97d8], I just updated to see if it would fix the problem, it did not)
Question
Okay so im making a multiplayer game, so I have a server, which is written in go, and the Godot client. My issue is from decoding a packet from the server.
Here is all of the relevant code for where the packet is received:
func recieve_packet(packet: String) -> void:
print("Packet: ", packet)
var pkt = JSON.parse_string(packet)
if pkt["type"] == "chunk":
main.receive_chunk_data(pkt["content"])
func receive_chunk_data(data: Dictionary):
#print(data["coords"])
var coords = data["coords"]
var tiles = data["tiles"]
loaded_chunks.append(coords)
map.generate_chunk(coords[0], coords[1], tiles)
So if I run this code normally i get this error:
Invalid access to property or key ‘tiles’ on a base object of type ‘Dictionary’.
thats on the line: var tiles = data["tiles"]
and if I look at the local stack variables, data is indeed a dictionary with only the field “coords”
and the print statement gives this, which shows that the “tiles” field is there:
Packet: {“type”:“chunk”,“content”:{“coords”:[248,248],“tiles”:[[[6,0,0],[6,0,0],[…
the tiles field is a 64x64x3 array
but if i add breakpoints to the two lines:
var coords = data["coords"]
var tiles = data["tiles"]
then when it stops at the first line and I check what the data variable contains it has both the “coords” and “tiles” fields and works just fine, but i have to manually tell it to continue every time.
So I would appreciate any insight into this problem and how I might be able to solve it!
Let me know if there is anything im missing that could help!