It looks like you're new here. If you want to get involved, click one of these buttons!
<<set $wheel to {
tyre : "michelin",
tyreDurability : 10
}>>
<<set $engine to {
brand : "mitsubishi",
speed : 10
}>>
/%Rest of fluff here%/
<<set $car to {
wheels : [$wheel, $wheel, $wheel, $wheel],
engine : $engine,
trunk : $trunk,
seats : [$seat, $seat, $seat, $seat, $seat]
}>>
takes up a huge amount of space in the passage and is very difficult to keep track of. It's easy to forget, say, a $car.wheels[2].tyreDurability to 17 when typing out about twenty other things. Additionally, if I wanted to have a cascading change, it's impossible to do that without typing it all out myself. For example, if I changed the car's overall brand from a Ford F-150 to a Reliant Robin, then in that very same section, I would have to change the engine, the wheels, etc. A better result would be that when I want to change the car's overall brand, I call a function that reads a global variable somewhere and changes anything that needs changing. Want to change the car's electronics? Function changes the GPS, Radio and heating system. Stuff like that.
Comments
As far as I'm concerned, ain't nothing better than a function to call on to do stuff, it should clean up your passages with considerably less clutter. If you're planning on using scripts and links to other passages simultaneously then I suggest making use of macros like click or button.
If you have further questions don't hesitate to put them forward.
Initialize:
<<set $showroom to { Honda: { engine: "honda", wheels: [ square, Square, Square, square], ...},
{ Ford: { engine: "ford", wheels: [ oval, oval, square, square] }}>>
...then you can...
<<set $car to clone($showroom.Honda)>>
...and it'll copy over all the variables you've got set up in your showroom. You'll need to keep any upgrades or hindrances that are supposed to be persistent in another structure.
One thing to be aware of, because of the way History works as soon as the Reader navigates to another passage the object referenced by your $wheel variable and the object referenced by your $car.wheels[0] variable will no longer be the same object, they will instead reference two new objects both of which will have the "same" value as the original.
This means that in the passage you defined the two variables in changing the value of $wheel.tyreDurability to 9 would also change the value of $car.wheels[0].tyreDurability to 9, but in any future passage changing the value of $wheel.tyreDurability to 8 will not change the value of $car.wheels[0].tyreDurability at all.