Hello,
New IF writer here :)
I am trying to generate a passcode with digits and letters. Well... digits only for now.
I would like to store a series of random numbers into a string.
I don't want to use random(0,9999) as I will add letters in the string later.
I manage to display my random-generated passcode with
(random: 0,9)(random: 0,9)(random: 0,9)(random: 0,9)
but can I store it into a string ?
I tried :
(set: $TestCode to ((random: 0,9)+(random: 0,9)+(random: 0,9)+(random: 0,9)))
which adds the numbers, and
(set: $TestCode to ((random: 0,9)+""+(random: 0,9)+""+(random: 0,9)+""+(random: 0,9)))
which causes a type mismatch error : the string "" isn't the same type of data as the number 9.
This question : http://twinery.org/questions/1606/twine2-harlowe-convert-integer-string-trying-random-encounters
brings an answer but it's quite cumbersome as every digit has to be stored in a variable :
(set: _First to (random: 0,9))
(set: _Second to (random: 0,9))
(set: _Third to (random: 0,9))
(set: $TempCode to (text:_First) + "A" + (text:_Second) + "B" + (text:_Third))
$TempCode
> 0A7B8 <- Success !
Is there an easier way ? Why can't I just use text:random(0,9) ?
Thanks !
Pip