Results 1 to 3 of 3

Thread: need help with script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default need help with script

    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.

  2. #2

    Default

    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?

  3. #3

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •