Need Help Creating Mahjong Tile Manager

Godot Version

4.5

Question

So I am in the process of making a silly mahjong game, but I want the tiles to be physical objects in a 3d world rather than 2D objects fanned accross your screen, but spawning them in procedurally is turning out to be real tough.

though, I am running into the issue of loading in the tiles. I don’t really want to go through and painstakingly make each tile it’s own scene and add them into the world that way, I’d like to do it through code, however, all of the tutorials I have watched have to do with 2D objects and use a lot of control nodes which don’t really apply to my use case.

I’ve now gotten to the point where I have the script create a custom resource for each tile and appends it to a wall, but they’re still just resources. My question is how would I go about creating a script that instantiates the tile, adds the resource containing all the data to it, and then places it randomly somewhere within the world.

My current plan is something like this:

I have a node labeled the TileManager, that somehow accesses the newly created wall, it then starts a for loop that instantiates a tile scene, adds a resource from the wall to a tile, and places it randomly on the table 4 times (since there are 4 copies of each tile besides the red 5 which I’ll have to figure out how to maneuver that) before moving on to the next resource in the list until there are no more resources left.

I would send screenshots of my code, but I nuked it in anger LOL. At least the tile_manager part, I have the generate_wall function still but I don’t think that’s my main problem right now. I just need to figure out how to access the newly made array of resources (the wall) in my separate tile_manager script. Or maybe Im taking the wrong approach?

I’ve heard about storing and accessing data through JSON files, is that what I should be looking to do for something like this? A lot of the tutorials I’ve been looking at for reference have been about poker, blackjack, western card games that don’t have nearly as many cards or variables to keep track of as mahjong. So it would make sense that a method that works for poker or something wouldn’t be as optimal for something like this maybe? Again, I don’t know squat, and I’ve been stuck on this for like 2 weeks lol.

Sorry if the problem is really vague, I don’t really know what I’m doing but I don’t wanna give up on this project just yet because it’s what really got my understanding started. I managed to figure out state machine logic and other stuff so it’d be really cool to actually get it working. Thanks again!

#ignore all the extra loops, those are artifacts from when I was trying to spawn in the tiles from the generate_tile function before I realized I was trying to position resources LOL