Var unchanged in *if tables (hacked around the problem)


#1

Rather long code but, I have the log that displays the code in the section I am running so I can check changes quickly. I have three *if tables that are chosen from a rand roll.The problem seems a var is not being changed in the second and third table. I have change the order around on which table is called first. Whichever table is first works without a hitch, second and third table will not change the var if the random roll is 8 or below. I have run this at least 50 times tracking the var and results in a notebook to see if it was something I was missing.The code below is what I started with. I even broke the code up over three pages along with a few other variations of the code still same results. Any Ideas what I am doing wrong or is this a CS bug? Thanks.

*comment set locations for Torif
*rand r_roll_2 1 20
*set r_roll r_roll_2
*gosub clothing_riverfront
*rand r_roll_3 1 20
*set r_roll r_roll_3
*gosub clothing_eastend
*rand r_roll_1 1 20
*set r_roll r_roll_1
*gosub clothing_downtown
*return

*label clothing_eastend
*if (r_roll=20) 
 *set clothing_eastend "Belle's Clothing"
 *return
*if (r_roll=19)
 *set clothing_eastend "Juliane's  Styles"
 *return
*if (r_roll=18)
 *set clothing_eastend "Rohie's Designs"
 *return
*if (r_roll=17)
 *set clothing_eastend "Rosewood's Boutique"
 *return
*if (r_roll=16) 
 *set clothing_eastend "Sashira's Trendy Clothing"
 *return
*if (r_roll=15)
 *set clothing_eastend "Wraith's Fashions"
 *return
*if (r_roll=14)
 *set clothing_eastend "Leigh's Apparel"
 *return
*if (r_roll=13)
 *set clothing_eastend "Camille's Outfitters"
 *return
*if (r_roll=12)
 *set clothing_eastend "Bellamy b Fashions"
 *return
*if (r_roll=11)
 *set clothing_eastend "Tori's Clothing"
 *return
*if (r_roll=10)
 *set clothing_eastend "Adrao's Styles"
 *return
*if (r_roll=9)
 *set clothing_eastend "Arcania Designs"
 *return
*if (r_roll=8)
 *set clothing_downtown "Hannah's Boutique"
 *return
*if (r_roll=7)
 *set clothing_downtown "Alex's Trendy Clothing"
 *return
*if (r_roll=6)
 *set clothing_downtown "Port3r's Designs"
 *return
*if (r_roll=5)
 *set clothing_downtown "Aera's Outfitters"
 *return
*if (r_roll=4)
 *set clothing_downtown "Weiss's Fashions"
 *return
*if (r_roll=3)
 *set clothing_downtown "Kira's Styles"
 *return
*if (r_roll=2)
 *set clothing_downtown "Braelyn's Boutique"
 *return
*if (r_roll=1)
 *set clothing_downtown "Misti's Apparel"
 *return

*label clothing_riverfront
*if (r_roll=20) 
 *set clothing_riverfront "Belle's Clothing"
 *return
*if (r_roll=19)
 *set clothing_riverfront "Juliane's  Styles"
 *return
*if (r_roll=18)
 *set clothing_riverfront "Rohie's Designs"
 *return
*if (r_roll=17)
 *set clothing_riverfront "Rosewood's Boutique"
 *return
*if (r_roll=16) 
 *set clothing_riverfront "Sashira's Trendy Clothing"
 *return
*if (r_roll=15)
 *set clothing_riverfront "Wraith's Fashions"
 *return
*if (r_roll=14)
 *set clothing_riverfront "Leigh's Apparel"
 *return
*if (r_roll=13)
 *set clothing_riverfront "Camille's Outfitters"
 *return
*if (r_roll=12)
 *set clothing_riverfront "Bellamy b Fashions"
 *return
*if (r_roll=11)
 *set clothing_riverfront "Tori's Clothing"
 *return
*if (r_roll=10)
 *set clothing_riverfront "Adrao's Styles"
 *return
*if (r_roll=9)
 *set clothing_riverfront "Arcania Designs"
 *return
*if (r_roll=8)
 *set clothing_downtown "Hannah's Boutique"
 *return
*if (r_roll=7)
 *set clothing_downtown "Alex's Trendy Clothing"
 *return
*if (r_roll=6)
 *set clothing_downtown "Port3r's Designs"
 *return
*if (r_roll=5)
 *set clothing_downtown "Aera's Outfitters"
 *return
*if (r_roll=4)
 *set clothing_downtown "Weiss's Fashions"
 *return
*if (r_roll=3)
 *set clothing_downtown "Kira's Styles"
 *return
*if (r_roll=2)
 *set clothing_downtown "Braelyn's Boutique"
 *return
*if (r_roll=1)
 *set clothing_downtown "Misti's Apparel"
 *return

*label clothing_downtown
*if (r_roll=20) 
 *set clothing_downtown "Belle's Clothing"
 *return
*if (r_roll=19)
 *set clothing_downtown "Juliane's  Styles"
 *return
*if (r_roll=18)
 *set clothing_downtown "Rohie's Designs"
 *return
*if (r_roll=17)
 *set clothing_downtown "Rosewood's Boutique"
 *return
*if (r_roll=16) 
 *set clothing_downtown "Sashira's Trendy Clothing"
 *return
*if (r_roll=15)
 *set clothing_downtown "Wraith's Fashions"
 *return
*if (r_roll=14)
 *set clothing_downtown "Leigh's Apparel"
 *return
*if (r_roll=13)
 *set clothing_downtown "Camille's Outfitters"
 *return
*if (r_roll=12)
 *set clothing_downtown "Bellamy b Fashions"
 *return
*if (r_roll=11)
 *set clothing_downtown "Tori's Clothing"
 *return
*if (r_roll=10)
 *set clothing_downtown "Adrao's Styles"
 *return
*if (r_roll=9)
 *set clothing_downtown "Arcania Designs"
 *return
*if (r_roll=8)
 *set clothing_downtown "Hannah's Boutique"
 *return
*if (r_roll=7)
 *set clothing_downtown "Alex's Trendy Clothing"
 *return
*if (r_roll=6)
 *set clothing_downtown "Port3r's Designs"
 *return
*if (r_roll=5)
 *set clothing_downtown "Aera's Outfitters"
 *return
*if (r_roll=4)
 *set clothing_downtown "Weiss's Fashions"
 *return
*if (r_roll=3)
 *set clothing_downtown "Kira's Styles"
 *return
*if (r_roll=2)
 *set clothing_downtown "Braelyn's Boutique"
 *return
*if (r_roll=1)
 *set clothing_downtown "Misti's Apparel"
 *return

#2
*comment Torif randomania

*label d20_rolls
*temp d20
*rand d20 1 20
*set r_roll d20
*return


*label clothing_eastend
*gosub d20_rolls
*if (r_roll=20) 
 *set clothing_eastend "Belle's Clothing"
 *return
*if (r_roll=19)
 *set clothing_eastend "Juliane's  Styles"
 *return
*if (r_roll=18)
 *set clothing_eastend "Rohie's Designs"
 *return
*if (r_roll=17)
 *set clothing_eastend "Rosewood's Boutique"
 *return
*if (r_roll=16) 
 *set clothing_eastend "Sashira's Trendy Clothing"
 *return
*if (r_roll=15)
 *set clothing_eastend "Wraith's Fashions"
 *return
*if (r_roll=14)
 *set clothing_eastend "Leigh's Apparel"
 *return
*if (r_roll=13)
 *set clothing_eastend "Camille's Outfitters"
 *return
*if (r_roll=12)
 *set clothing_eastend "Bellamy b Fashions"
 *return
*if (r_roll=11)
 *set clothing_eastend "Tori's Clothing"
 *return
*if (r_roll=10)
 *set clothing_eastend "Adrao's Styles"
 *return
*if (r_roll=9)
 *set clothing_eastend "Arcania Designs"
 *return
*if (r_roll=8)
 *set clothing_downtown "Hannah's Boutique"
 *return
*if (r_roll=7)
 *set clothing_downtown "Alex's Trendy Clothing"
 *return
*if (r_roll=6)
 *set clothing_downtown "Port3r's Designs"
 *return
*if (r_roll=5)
 *set clothing_downtown "Aera's Outfitters"
 *return
*if (r_roll=4)
 *set clothing_downtown "Weiss's Fashions"
 *return
*if (r_roll=3)
 *set clothing_downtown "Kira's Styles"
 *return
*if (r_roll=2)
 *set clothing_downtown "Braelyn's Boutique"
 *return
*if (r_roll=1)
 *set clothing_downtown "Misti's Apparel"
 *return

*label clothing_riverfront
*gosub d20_rolls
*if (r_roll=20) 
 *set clothing_riverfront "Belle's Clothing"
 *return
..........copy n paste old code...........

*label clothing_downtown
*gosub d20_rolls
*if (r_roll=20) 
 *set clothing_downtown "Belle's Clothing"
 *return
......copy and paste rest of code here..........

Gosub to your dice rolls from the clothing stops that should fix your problem. As I do not know what the code looks like prior to your code it is better to use a gosub to a random (especially if you use that dice rolls a lot like d20, d10, or whatever numbers you to random a lot with.


#3

I gosub from startup then return then goto_scene p_1 that gives the choice to goto shop location then shopping. If I gosub from the shop names would keep changing.


#4

While what you suggest would not work for my mad purposes but a thought did manifest for a check for unchanged various before continuing. Won’t be able to test my theory for a day or two but thanks for the thought. :smile:


#5

Manage to hack around the problem. Does not really resolve the issue per say but works around it nicely.

*rand r_roll_2 1 20
*set r_roll r_roll_2
*gosub_scene loc_1 clothing_riverfront
*label step_1
*if (clothing_riverfront="Unchanged")
 *rand r_roll_2 1 20
 *set r_roll r_roll_2
 *gosub_scene loc_1 clothing_riverfront
 *goto step_1
*else
 *goto step_2

*label step_2
*rand r_roll_3 1 20
*set r_roll r_roll_3
*gosub_scene loc_1 clothing_eastend
*label step_3
*if (clothing_eastend="Unchanged")
 *rand r_roll_3 1 20
 *set r_roll r_roll_3
 *gosub_scene loc_1 clothing_eastend
 *goto step_3
*else
 *goto step_4

*label step_4
*rand r_roll_1 1 20
*set r_roll r_roll_1
*gosub_scene loc_1 clothing_downtown
*label step_5
*if (clothing_downtown="Unchanged")
 *rand r_roll_1 1 20
 *set r_roll r_roll_1
 *gosub_scene loc_1 clothing_downtown
 *goto step_5
*else
 *goto step_6

*label step_6
*goto_scene shop_t