Still cutting my teeth on the basics and while I have a major component working in my code, I’m hoping to tighten a few hundred lines of code into something more workable.
I’m using the newer material mapping from verse.assets.digest - it’s essential to my card game. But either because I’m too green to understand, since each material seems to be declared like a separate type, I’m wondering if it’s even possible to simplify this (it may not be?)
So I’ve got dozens of the following blocks with names like Mat_CBx:
var Mat_CB1 : Card_Textures.Root_Materials.CB_Slot_1_material = Card_Textures.Root_Materials.CB_Slot_1_material{}
var Mat_CB1_SpAb_Top : Card_Textures.Root_Materials.SpAb_Top_1_material = Card_Textures.Root_Materials.SpAb_Top_1_material{}
var Mat_CB1_SpAb_Mid : Card_Textures.Root_Materials.SpAb_Middle_1_material = Card_Textures.Root_Materials.SpAb_Middle_1_material{}
var Mat_CB1_SpAb_Btm : Card_Textures.Root_Materials.SpAb_Bottom_1_material = Card_Textures.Root_Materials.SpAb_Bottom_1_material{}
var Mat_CB1_RX : Card_Textures.Root_Materials.RX_Slot_1_material = Card_Textures.Root_Materials.RX_Slot_1_material{}
name_subname_x_material are all connected to my device and creative_props later in the code…
A ton of my code is taken up by this… and I haven’t figured out any type casting on this sort of stuff - any ideas to make this code tighter, a.k.a. some sort of loop?
Yeah, they’re materials that are referenced in Assets.Digest.
I tried creating a class or three that had something like
MyMats : material = material{}
and even
MyMats : material = Card_Textures.Root_Materials.CB_Slot_1_material{}
and nothing worked, I think it’s because how you have to append “_material” when referring to the assets.digest file… so I guess I have a specific ‘type’ for each of my 100+ material mappings?
Apologies, I know I’m not being terribly clear on this but it’s in large part because I’m still trying to get my bearings on calling materials this way and verse in general. Appreciate your perspective regardless.
Tried that rather early on though I forgot the bug that it produced.
It’s on my list of things to do, but given the complexity of the project I’m kind of stuck with it. I mean it’s fine as is at the end of the day, I’m the only one going over the code, but I want to know better options going forward.
I’m already doing that in a few files for textures - I’m just connecting the materials here so I can swap out one of about 500 textures that are defined in mapped arrays in a variety of files.