PDA

View Full Version : need help with script



Eliseen
02-21-2021, 02:22 PM
So I'm trying to make a script for "role playing". I call it joke. the command would be ;joke subject. So if you entered ;joke critter it would branch to a routine that would randomly select 1 of 10 random jokes. Here is a snipet:


if joke_script =~ /critter/
joke_critter = rand(10)


fput "say What is red small monster thas a pink spotted head, sixteen hairy legs and four big eyes on finger like things? I don’t know either but there is one crawling up your back!" if joke crittter == 0

fput "say :forceful What is big, yellow and prickly, has three eyes and eats rocks? A big, yellow, prickly three eyed rock eater!" if joke_critter == 1


etc.

fput "joke 9" if joke_critter == 9



end

My problem is there will be multiple sections one for each subject, I Tried an reg_ex to allow the proper section to generate a random joke, I know that part works as I've used the random expression in the past. How do I get the script to execute that one section among all the others?

Any help would be appreciated.

Jymamon
02-21-2021, 06:21 PM
Assuming your subject has already been put into the joke_script variable, what you have would work (though not really how I would write it... you might want to look into Ruby's "case" statement for better organization). What you have is only going execute everything up to the "end" when "joke_script =~ /critter/" evaluates to true. If joke_script = town, foir example, it would run any of those statements. What is your full script and what part isn't working the way you want?

Eliseen
02-25-2021, 07:50 AM
Like always I messed up on the syntax. I changed the initial if joke_script parenthesis and it works now. Now all I have to do is come up with a lot of jokes for different occasions.