I am working on a kind of factory game. (I’ll use psuedo code here because my actual code is pretty tangled at the moment, but the concepts should be easy to understand.) Imagine I have many different factories: Fa, Fb, Fc, etc. Now, each of those factory types has various Resource (Ra, Rb, Rc, Rd, etc.) used for Inputs and Outputs of varying quantities.
Example:
Fa Inputs: 2xRa + 1xRd = Outputs: 2xRb
Fb Inputs: 1xRa + 1xRb + 3xRc = Outputs: 1xRe + 2xRf
And so on.
(Additionally, there can be multiple factories of each type in play.)
I would like to build each factory object with its own Structure variable, such as:
Fa:
Process {Structure}
- Inputs {Structure}
- Ra Number 2
- Rd Number 1
- Outputs {Structure}
- Rb Number 2
Fb:
Process {Structure}
- Inputs {Structure}
- Ra Number 1
- Rb Number 1
- Rc Number 3
- Outputs {Structure}
- Re Number 1
- Rf Number 2
I would love to be able to iterate through each object’s Inputs and Outputs independently, but For Each Child does not work for object structures (only Scene structures). However, if I build these factory structures as Scene structures, I run into the problem of trying to tie the Factory Name into the Scene Structure name.
With the factories in a Scene Structure, I’ve tried to write something like this:
Repeat for each instance of groupFactory:
For every child in Process[groupFactory.ObjectName()].Inputs, store child variable in Process[groupFactory.ObjectName].ChildValue, the child name in Process[groupFactory.ObjectName().ChildName and do:
[…]
But this does not work. There doesn’t seem to be a way to dynamically insert the groupFactory.ObjectName() into the necessary places of the For every child string on the fly.
I have tried setting the groupFactory.ObjectName() as a scene string (like: scnTempString), but this causes each factory to constantly reset this scene variable to it’s own ObjectName.
This would be so easily solved if I could iterate through each Object’s structure variables, but I’m stumped as to how to make a scalable solution to this factory problem. Please let me know if there are any workarounds dealing with the children of multiple object structures.
Thanks,
Tom