Post your questions and help other users.
Moderator: Martin
-
bichlepa
- Posts: 148
- Joined: 04 Mar 2014 18:29
- Location: Germany
-
Contact:
Post
by bichlepa » 25 May 2016 16:32
I'm trying to use maps which are inside other maps.
I have a map named "global_gamestate". The map contains other maps e.g. "red". So I can get or set a value using
Now my problem: I want to make a copy of "global_gamestate", but if I use the function copyMap, it does not copy the submaps.
-
Martin
- Posts: 4468
- Joined: 09 Nov 2012 14:23
Post
by Martin » 25 May 2016 19:20
Yes, copyMap creates a flat copy (shallow copy). You can either copy the maps within the map manually by looping over the main map or you could temporarily convert the map to JSON and back.
A script could look like this:
map = newMap();
...
copy = fromJSON(toJSON(map));
Regards,
Marti