*if (variable = variable) *goto


#1

Hi,

I’m having trouble checking whether two text variables are the same, then going back to the start of the randomisation sub-routine if they are.

Is this just not possible? Are there workarounds?

Thanks!

Simplified version:
(this was created to allow the randomisation of two colours, like ‘red and black’ or ‘white and green’, allowing one randomised variable to be used in place of two variables.)

*label double_colour_adjective

*rand var 1 2
*set first_colour_adjective "first_colour_adjective_"&var
*gotoref first_colour_adjective

*label first_colour_adjective_2
*set first_colour_adjective "black "
*goto choose_second_colour_adjective

*label first_colour_adjective_1
*set first_colour_adjective "white "
*goto choose_second_colour_adjective

*label choose_second_colour_adjective
*rand var 1 2
*set second_colour_adjective "second_colour_adjective_"&var
*gotoref second_colour_adjective

*label second_colour_adjective_2
*set var "and black"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_1
*set var "and white"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label double_colour_adjective_check
*if (first_colour_adjective = var)
  *goto double_colour_adjective
*return

#2

I think you need to use *gosub for the check label, not *goto


#3

I’ve changed it to go_sub, but no luck yet. (Wouldn’t that require the *return to function twice but in different… um directions?)

Thanks @Scribblesome

Link to this single page CS experiment, for anyone to see what’s going on (each time you hit play again everything should change):

https://dl.dropboxusercontent.com/u/47183494/Example%20of%20randomisation%201/web/index.html


#4

I not sure I follow so this may not help you but if I have the right idea this is how I would handle it.

*label double_colour_adjective

*rand var 1 2
*gosub check
*if (first_colour_adjective="black")
  *set second_color_adjective "red"
  *goto someplace
*if (first_colour_adjective="red")
  *set second_color_adjective "black"
  *goto someplace

*label check
*if (var=2)
  *set first_colour_adjective "black"
  *return
*if (var=1)
  *set first_colour_adjective "red"
  *return

#5

That makes sense, thanks @Lordirish, but wouldn’t you have to write an individual piece of code for each pairing?

Non simplified version is now below - but you’ll get the jist if I just say that I’m after an infinitely repeatable piece of code I can copy and paste.

At the moment I just change the var label number and the colour.

*set noble_Lydian_1_house_colours double_colour_adjective

----

*label double_colour_adjective

*rand var 1 11
*set first_colour_adjective "first_colour_adjective_"&var
*gotoref first_colour_adjective

*label first_colour_adjective_11
*set first_colour_adjective "pink "
*goto choose_second_colour_adjective

*label first_colour_adjective_10
*set first_colour_adjective "yellow "
*goto choose_second_colour_adjective

*label first_colour_adjective_9
*set first_colour_adjective "orange "
*goto choose_second_colour_adjective

*label first_colour_adjective_8
*set first_colour_adjective "red "
*goto choose_second_colour_adjective

*label first_colour_adjective_7
*set first_colour_adjective "brown "
*goto choose_second_colour_adjective

*label first_colour_adjective_6
*set first_colour_adjective "purple "
*goto choose_second_colour_adjective

*label first_colour_adjective_5
*set first_colour_adjective "grey "
*goto choose_second_colour_adjective

*label first_colour_adjective_4
*set first_colour_adjective "green "
*goto choose_second_colour_adjective

*label first_colour_adjective_3
*set first_colour_adjective "blue "
*goto choose_second_colour_adjective

*label first_colour_adjective_2
*set first_colour_adjective "black "
*goto choose_second_colour_adjective

*label first_colour_adjective_1
*set first_colour_adjective "white "
*goto choose_second_colour_adjective

*label choose_second_colour_adjective
*rand var 1 11
*set second_colour_adjective "second_colour_adjective_"&var
*gotoref second_colour_adjective

*label second_colour_adjective_11
*set var "and pink"
*set double_colour_adjective first_colour_adjective&var
*return

*label second_colour_adjective_10
*set var "and yellow"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_9
*set var "and orange"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_8
*set var "and red"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_7
*set var "and brown"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_6
*set var "and purple"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_5
*set var "and gray"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_4
*set var "and blue"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_3
*set var "and blue"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_2
*set var "and black"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label second_colour_adjective_1
*set var "and white"
*set double_colour_adjective first_colour_adjective&var
*goto double_colour_adjective_check

*label double_colour_adjective_check
*if (first_colour_adjective = var)
  *gosub double_colour_adjective
*return

#6

I could write it all in one code I do believe give me a few min. and I will see what I can brew up.


#7

Your title should be Old Reliable :slight_smile: you’re very kind @Lordirish


#8

lol I am far from a master at CS like some of the others around here, but I can always find a work around, may not be pretty or short at times but it will function :slight_smile:


#9

Yeah, you don’t even want to look at the coding required to randomise the other parts of the two sentences shown in the link above…
pretty and short doesn’t even come into it. I think there are about 9 scene files for that handful of sentences :sweat_smile:


#10

I have a good feel for this but may take me 10 to 15 min to write but it will repeat until all are place and can be reused many times.


#11

Why not create the vars as numbers, check the numbers against each other, then set colours? That might make it less complicated with the amount of labels. Like
*rand num1 1 2
*label num2set
*rand num2 1 2
*if num1=num2
___*goto num2set
*else
___*goto colourset

And then you can do the if num1=1, colour1=“red”, stuff


#12

@Scribblesome That would definitely take less time than the most recent proposition. Thanks!

Let’s see what @Lordirish proposes :smirk: (no pressure Old Faithful) :ocean:

Your example =

*gosub_scene zz_adjective double_colour_adjective

----------

*label double_colour_adjective

*rand num1 1 3 
*rand num2 1 3
*if (num1 = num2)
___*goto double_colour_adjective
*if (num1 = 1)
___*set firstcolour "red "
*if (num1 = 2)
___*set firstcolour "blue "
*if (num1 = 3)
___*set firstcolour "yellow "
*if (num2 = 1)
___*set firstcolour "and red"
*if (num2 = 2)
___*set firstcolour "and blue"
*if (num2 = 3)
___*set firstcolour "and yellow"
*return


----------

*set noble_Lydian_1_house_colours double_colour_adjective

#13

Nearly done but will not have tested, will put up the code here in a few then go back and test.


#14

This is the quickest way I could think of to ensure that no color was reused and keep the code smallist and reusable. I still need to test.

(bad code removed)

Causes a long loops and can freeze up but I think I can improve the code give me a few.


#15

Here @LordIrish:

appears to work :grin:
https://dl.dropboxusercontent.com/u/47183494/Example%20of%20randomisation%201/web/index.html

Quote:
Viscount Henley Lindcomb is a human male. He is quite tall and has brown eyes.

His house colours are green and grey. Some people call him ‘the Bastard’.

*comment any time you need to use the code always start with reset


*label double_colour_adjective1
*label reset
*set pink false
*set yellow false
*set orange false
*set red false
*set brown false
*set purple false
*set lilac false
*set grey false
*set green false
*set blue false
*set black false

*temp hold ""

*gosub fill
*set first_colour_adjective hold
*gosub fill
*set second_colour_adjective hold
*gosub fill
*set double_colour_adjective first_colour_adjective&space_and_space
*set double_colour_adjective double_colour_adjective&second_colour_adjective
*return

*label fill
*rand var 1 11
*if (var=11)
  *if (pink)
    *gosub fill
    *return
  *else
    *set hold "pink"
    *set pink true
    *return
*if (var=10)
  *if (yellow)
    *gosub fill
    *return
  *else
    *set hold "yellow"
    *set yellow true
    *return 
*if (var=9)
  *if (orange)
    *gosub fill
    *return
  *else
    *set hold "orange"
    *set orange true
    *return 
*if (var=8)
  *if (red)
    *gosub fill
    *return
  *else
    *set hold "red"
    *set red true
    *return 
*if (var=7)
  *if (brown)
    *gosub fill
    *return
  *else
    *set hold "brown"
    *set brown true
    *return 
*if (var=6)
  *if (purple)
    *gosub fill
    *return
  *else
    *set hold "purple"
    *set purple true
    *return 
*if (var=5)
  *if (grey)
    *gosub fill
    *return
  *else
    *set hold "grey"
    *set grey true
    *return 
*if (var=4)
  *if (grey)
    *gosub fill
    *return
  *else
    *set hold "lilac"
    *set lilac true
    *return 
*if (var=3)
  *if (green)
    *gosub fill
    *return
  *else
    *set hold "green"
    *set green true
    *return 
*if (var=2)
  *if (blue)
    *gosub fill
    *return
  *else
    *set hold "blue"
    *set blue true
    *return 
*if (var=1)
  *if (black)
    *gosub fill
    *return
  *else
    *set hold "black"
    *set black true
    *return

startup.txt

*create first_colour_adjective “”
*create second_colour_adjective “”
*create space_and_space " and "
*create pink false
*create yellow false
*create orange false
*create red false
*create brown false
*create purple false
*create lilac false
*create grey false
*create green false
*create blue false
*create black false


#16

Woot got it to work and fast :smile:

(bad code removed)

missed one false statement change in the code above. Yellow was set to true but changed to false.


#17

I’ve got to say a big thank you to you and @Scribblesome for helping me with this!

(didn’t spot the yellow either!)


Now, does anyone know how to build a computer fast enough to run this game when it has thousands of similar go_sub routines? :yum:


#18

I use tons but once compiled have not noticed any problems.

Hmm still have a bug after changing the yellow to false it goes back to long loop problem I am going to figure this out if it kills me know lol.


#19

Quick stupid question.

Do we still compile stuff? I’ve done it a couple of times, but these days isn’t that done by the app magicians at H&G ltd?

I can’t imagine its fun to recompile each time you want to test something through. I seem to remember it took a little while


#20

It goes very quick for me, but I am using CSIDE which I am hoping will be out of beta very soon, greatest tool for working in CS built by @CJW

Alright I think I I have it resolved but having to recode one last time. The loop is far to long so I think by breaking it up and reset half to a color will resolve the problem. Should only take me a few