I’m currently in the process of coding my first chapter for my Game Civil Evolution since I’m likely to encounter many, many errors which I may not know how to get around I’ll just post them all here.
I’m currently trying to create a series of Generators that “create” random values like the Person name, gender and what race they are uplifting.
I’m using the *gosub command to go to each generator in turn
The only thing I see that could be problematic is the part that you create the variable “Companion1Gener false” but later use Companion1gener. The G in Gener is small. I don’t know how the CS checks variables but that could be a problem.
Edit: Also I think you should only use lower case letters for CS variables but I am not sure.
Okay, so, because I’m not clear on what you’re trying: First: don’t use *if or subroutines to *create variables. *create commands should all go in the top of the startup file. *create, *scene_list, *title, *author, and *achievement are all Initial Commands. One any other command is used, those commands are permanently closed with only *comment being a special case. (This is bug prevention.)
the *Create are in the Setup.txt at the top as they should be I’ve only included them to show that I have created the variables I’m calling. there are no *create after the main block of code starts I have only used *temp after that point,
the Error points to *set {companionx}Gender "man" or *set {companionx}Gender “woman” when it generates the error
I will read throu your link there and see if I can spot a solution thou.
Ok, I think it doesn’t like you putting the ‘$’ in the *set command. You may need a hold variable in there to set the variable name.
Assuming you have something like this in your startup.txt
*create Alice_gender ""
*create Bob_gender ""
Then something like this should work:
*temp holdvar ""
*set companionx "Alice"
*set holdvar "${companionx}_gender"
*set {holdvar} "woman"
*set companionx "Bob"
*set holdvar "${companionx}_gender"
*set {holdvar} "man"
Alice is a ${Alice_gender}.
Bob is a ${Bob_gender}.
My code is now working
I created 8 holding variables which I can move companion data in and out of. which will be useful later as well when I start writing the companions interlude stories.
And this is my new generator code for reference, I’ve tested it and it works without a problem.
Thanks, @ChibaHateme, @RETowers, @Scribblesome, for helping me work through my issue!
You might run into trouble with the {} again. I tried it out and I could get it to set `companionxdistance` but not `{companionxdistance}`.
I think it only rounds to the integer, though.
I suppose it would be possible to round to the integer after multiplying by 100 if you wanted two decimal places, and then divide the resulting quantity by 100 after the number was rounded…something like:
I think you probably have declared every one of them as numeric by giving them the starting value 0. However, if you didn’t this could lead to the problem. But I would also think the code wouldn’t work as a whole if the Distance isn’t already declared as numeric.
Fiogan’s idea is quite nice I would say. However, I would rather multiply dis1 by 100 and add the value of dis2 onto it. Then I would round it and divide it by 100 at the end. With this, the first step should only produce integer numbers between 100 and 600. Fiogan’s example does the same but I am a bit scared of the operation dis2/100. I would avoid decimal numbers as long as possible.