*rand help, or randomness in general


#1

Hello, I’m currently making a Tarot Card System for the WIP game I’m working on. Within it, I want to give the players a chance to have their fortune told, pretty much. I’ve tried *goto_random_scene, but for that, I would have to add over 78 different scenes within the *startup.txt, which is… rather impractical.

The best form of coding I’ve found so far is the *rand, but with the *rand, of course, you can reroll what you get simply by going to the Stat Screen. I’ll be adding stats by whichever of the 78 different cards you get. So, I feel, this would be a good way to cheat within the game…

Anyways, is there a way for me to be able to get the *rand going without them being able to reroll what they get? Thank you so much! Or if there’s a better way for me to do this, and give them a random *label in general, I would much appreciate it.

This is what my *rand coding looks like at the moment:

(Note that there are only 10 options below, but when finished there will be 26 different cards, over three choices, for 78 different outcomes.)

*rand code:
*temp tarotcard


*rand tarotcard 1 10
*if (tarotcard=1)
 *set t_fool true
 *gosub t_fool
*if (tarotcard=2)
 *set t_empress true
 *gosub t_empress
*if (tarotcard=3)
 *set t_lovers true
 *gosub t_lovers
*if (tarotcard=4)
 *set t_hermit true
 *gosub t_hermit
*if (tarotcard=5)
 *set t_hanged_man true
 *gosub t_hanged_man
*if (tarotcard=6)
 *set t_devil true
 *gosub t_devil
*if (tarotcard=7)
 *set t_moon true
 *gosub t_moon
*if (tarotcard=8)
 *set t_world true
 *gosub t_world
*if (tarotcard=9)
 *set ace_of_c true
 *gosub ace_of_c
*if (tarotcard=10)
 *set a4_of_c true
 *gosub a4_of_c
*page_break

I tried adding the *page_break at the end to keep the player from being able to reroll their outcome, but, of course, it didn’t work. This is what one of the tarot cards look like:

*label t_empress
This is random placeholder text for t_empress
*page_break
*goto secondcard

Anyways, thanks ahead of time, and I apologize if I’m being dumb with how I’m trying to go about this lol.


#2

Would something like this work?

*temp have_made_random_roll false
*if not (have_made_random_roll) 
	*rand tarotcard 1 10
	*set have_made_random_roll true
*elseif (tarotcard = 1)
	*set t_fool true
	*gosub t_fool
*elseif (tarotcard = 2)
	*set t_empress true	
	*gosub t_empress

and so on with each card


#3

Let me give it a try and see! Thank you!


#4

So, I built a card machine a while back that relied on using extracted letters from a string that represented the deck. So I had a key with something like “A”= Ace of spades, “B”=2 of spades, “N”= Ace of clubs, “a”= Ace of diamonds, etc., and a string that was “ABCDEFGHIJKL[…]XYZabcdef[…]xyz”, which I then shuffled by splitting into two different variables, then compiled together using a weight draw to randomly pick from each of them. I could then read off that by using hand#1, to extract the letter and tell me what the card was via a subroutine.

Of course, with the inclusion of the major arcana, and the minor arcana being 56 rather than 52, you’re probably going to have to use a grouped system where three parts of the string in a row would represent a single card.

(Of course, in practice, I’d recommend you just dispense with the idea of having an arbitrary read, and instead lock it to either one, or maybe a couple, tailored to the needs of the story.)


#5

Thanks for sharing that!

My plans were to have the player pick one card, with a total outcome of 26 random cards (outcomes).
Then another possibility of 26 different cards,
and then once more with another 26 different cards.

So, something along the lines of (18 Minor Arcana / 8 Major Arcana), and so forth. All cards will only have the possibility of being picked, but only within the group of three that they are assigned too. I know, it’s confusing. >.<

I’ll see if I can’t get something going with what you linked above, seeing as the *rand doesn’t seem to work for me sadly.


#6

I ended up figuring out how to get this working correctly. Rather than having them all being in the same *scene file, I split them in two and pretty much had to manhandle it a bit haha. This is how it ended up turning out:

scene = random_cards
*label startofreading
*comment Są to pierwsze możliwe z 26 kart. Dla drugiej i trzeciej opcji będzie również 26 do wyboru./ / /

*temp tarotcard

*if have_made_random_roll1 = false
 *rand tarotcard 1 10
 *set have_made_random_roll1 true

*if (tarotcard=1)
 *set t_fool true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=2)
 *set t_empress true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=3)
 *set t_lovers true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=4)
 *set t_hermit true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=5)
 *set t_hanged_man true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=6)
 *set t_devil true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=7)
 *set t_moon true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=8)
 *set t_world true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=9)
 *set ace_of_c true
 *gosub_scene cardsandmeaning
*elseif (tarotcard=10)
 *set a4_of_c true
 *gosub_scene cardsandmeaning
scene = cardsandmeaning
*if t_fool = true
	*goto t_fool
*elseif t_empress = true
	*goto t_empress
*elseif t_lovers = true
	*goto t_lovers
*elseif t_hermit
	*goto t_hermit
*elseif t_hanged_man
	*goto t_hanged_man
*elseif t_devil
	*goto t_devil
*elseif t_moon
	*goto t_moon
*elseif t_world
	*goto t_world
*elseif ace_of_c
	*goto ace_of_c
*elseif a4_of_c
 *goto a4_of_c

and then pretty much the *labels :slight_smile:

Thanks both of you for the help! I guess sometimes things have to be pushed and slapped around to work.


#7

So glad I was able to contribute! It’ll be cool to see everything in action in your WIP. Good luck!