• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Calling Script Twice to Generate Multiple Families of Objects?

B

Blueoriontiger

Guest
Hello,

Long story short, I have a tile-matching game that gets its data from a JSON file, as an array. When one enters the playing area, a script generates the play area as an object from the JSON, creating the area where the player can drag the right tiles to the correct spot.

The datasets are organized by a "family", so if tiles of a different family are spawned, they will not fit into the tileset.

I want to make an area where multiple families of objects are spawned, so the player has 2-3 different areas to contend with. However, I can't seem to get it to spawn more than one group at a time.

This is my code below that calls the script to spawn the tiles. This is in the Create section of an invisible object in the play area, and Script_Game_CreateMatchData is the actual script that's called:

-

if(room == Room_Game_Alone)
{

gameDataMap = json_decode(Script_Game_CreateMatchData(6)) //number in brackets denotes which family spawns; -1 for a random family.

name = gameDataMap[?"name"]
description = gameDataMap[?"description"]
optionBlocksList = gameDataMap[?"optionBlocksList"]
jsonAnswers = json_encode(gameDataMap[?"Answers"])

pagNum = ceil(ds_list_size(optionBlocksList)/2/displayNum)

Script_Game_CreateAnswers(jsonAnswers,name)

event_perform(ev_other,ev_user0)

}
else
{

-

Someone told me if I call the function twice and change the family in the 2nd call, I'll be able to get it to spawn with multiple blocks. But for the life of me I cannot figure out how to get it to call a second time. I've tried repeating json_decode to no success; I also realize if I try to give it a different variable, it'll not plug in directly to the scorekeeping and UI displays I have set up.

Any suggestions are appreciated. Thanks.
 

Attachments

D

Danei

Guest
Does Script_Game_CreateMatchData() do anything besides choosing a string?

Also, what did your code look like when you tried using json_decode() again to no success?
 
B

Blueoriontiger

Guest
Script_Game_CreateMatchData() generates the answer tiles, generates some fake ones along with the real ones, and returns data. I copy-pasted it here.

When I did gameDataMap = json_decode(Script_Game_CreateMatchData(x)) again, (putting the statement twice), absolutely nothing happened.
 
D

Danei

Guest
Overwriting the decoded JSON with a new decoded one isn't going to do anything unless you access the appropriate values from the old one and then the new one in turn and combine them where appropriate. For example, it seems like you'd want optionBlocksList to be a combination of the list from the first JSON and the list from the second JSON, right? Or something like that, anyway? What about jsonAnswers? Is that going to be any different if you're using multiple families? It's hard to know exactly what code you need to add without knowing exactly what data you need to end up with.
 
Top