It looks like you're new here. If you want to get involved, click one of these buttons!
I get error messages when doing this:
Prompt: Population {} {5000}
MaxReps: 1
Set: pop={$Prompt1}
Set: density={1d6+4}
Set: num={round({{$pop}/{$density}})}
Set: nc={round({{$num}/2})} // Number of crofts
Set: nh={round({{$num}/11})} // Number of cottages
Set: t1={{$num}-{$nc}} // Subtract crofts
Set: nb={{$t1}-{$nh}} // Subtract cottages for # of remaining buildings
Table: main
Village (pop. {$pop})\nBuildings: {$num}\nCottages: {$nh}\nCrofts: {$nc}\nShops: {$nb}
pop isn't being set which causes a cascading set of errors.
Village (pop. )
Buildings: (Invalid expression: round((Invalid expression: /10)))
Cottages: (Invalid expression: round((Invalid expression: (Invalid expression: round((Invalid expression: /10)))/11)))
...
From looking at other examples of Prompt, that seems fine though the other examples have all been text input and not numeric. What am I missing. Thanks!
Comments
Try Define: for calculations that are constant and don't have the randomness of a die roll. This code works (at least with no errors, and a hand check of the results looks good):
Now then, since $density is a die roll that, once rolled, must maintain the same value for the duration of the Rep, it must use the Set: definition, or else every following variable will reroll a new 1d6+4 to determine its value. The result of using Define: for {$density} would be the total number of buildings would not add up and the ratio of crofts to cottages, etc would not be calculated using a consistent density value.
I find Set: and Define: to be a bit confusing and usually have to try variations of each with hand checking the results before I'm confident in the way I'm using them.
Note: I usually don't place the {5000} in brackets, but it doesn't seem to cause any problems here.
Thanks! That is pretty weird. I had only just added the Prompt input to what had been a working table with a random pop value.
Thanks for pointing me at the define option.