Page 3 of 10 FirstFirst 12345 ... LastLast
Results 21 to 30 of 99

Thread: my script questions

  1. Default

    So if you want to just let us know where you are dropping all these gems I would be happy to come collect them all...

  2. #22

    Default

    [Secret Hidehout - ]
    You notice a massive pile of gems.
    Obvious exits: none

  3. #23

    Default

    Quote Originally Posted by onurb View Post
    --- Lich: dropgem active.
    --- Lich: error: undefined method `times' for "5 green":String
    dropgem:5:in `_script'
    C:/Lich5/lich.rbw:802:in `eval'
    --- Lich: dropgem has exited.


    the activator or get was "need 5 green glimaerstone"
    What exactly is the line you are trying to match? Remember . matches anything and * is greedy, meaning it is going to match as much as it can.

  4. Default

    Quote Originally Posted by onurb View Post
    --- Lich: dropgem active.
    --- Lich: error: undefined method `times' for "5 green":String
    dropgem:5:in `_script'
    C:/Lich5/lich.rbw:802:in `eval'
    --- Lich: dropgem has exited.


    the activator or get was "need 5 green glimaerstone"
    I think you might have needed to do need 5 "green glimaerstone" or something to that effect.

  5. #25

    Default

    I got it to work by adding ' on each side of the (.*)
    prior to that it wasnt capturing the line coming in. I had to also do a "say '#{gem_quantity}' '#{gem_name}'" on the other script with ' on each side there too. For some reason it did not like the space between the two (.*)

    Code:
    while line = get
    	if line =~ /"need '(.*)' '(.*)'"/
    		gem_quantity = $1
    		gem_name = $2
    		gem_quantity.times{ 
    			fput "get #{gem_name} from my knapsack"
    			fput "drop #{gem_name}"
    		}
    	end
    end

  6. #26

    Default

    Quote Originally Posted by onurb View Post
    I got it to work by adding ' on each side of the (.*)
    prior to that it wasnt capturing the line coming in. I had to also do a "say '#{gem_quantity}' '#{gem_name}'" on the other script with ' on each side there too. For some reason it did not like the space between the two (.*)

    Code:
    while line = get
    	if line =~ /"need '(.*)' '(.*)'"/
    		gem_quantity = $1
    		gem_name = $2
    		gem_quantity.times{ 
    			fput "get #{gem_name} from my knapsack"
    			fput "drop #{gem_name}"
    		}
    	end
    end
    Ah I see. So one character is basically saying "I need 10 diamonds" and the other character grabs 10 diamonds and drops them?

    That makes sense then. But I too would like to know where all of these gems are being dropped......

    Also might want to be careful with this, if someone knows your characters they could make your character drop gems by saying this in front of them

  7. #27

    Default

    Quote Originally Posted by Tgo01 View Post
    Ah I see. So one character is basically saying "I need 10 diamonds" and the other character grabs 10 diamonds and drops them?
    yep, thats exactly whats happening. just trying to reduce some regular tedius typing

    Quote Originally Posted by Tgo01 View Post
    Also might want to be careful with this, if someone knows your characters they could make your character drop gems by saying this in front of them
    you make a good point, I will have to change the text. though my chars don't exactly walk around town with this script on.

  8. #28

    Default

    Quote Originally Posted by onurb View Post
    you make a good point, I will have to change the text. though my chars don't exactly walk around town with this script on.
    True. Just a good idea to try and make the regex as close to the whole line as possible to avoid any sort of shenanigans.

    For example you could make the regex:

    ^(?:Bob|Jerry) says, "need '(.*)' '(.*)'

    The ^ symbol means that's the start of the line, so no one can do any sort of shenanigans to try and trigger the code by whispering you "Dreaven says, "need '10' 'diamonds'", because then the start of the line would be "Bob whispers you blah blah blah."

    This part:

    (?:Bob|Jerry)

    Means that word has to be either Bob or Jerry, so you can enter all of your characters here to ensure the script only triggers when one of your characters say it. You can enter as many character names as you want, just separate them each with the | symbol. The ?: just means this group won't be counted as a regex group so it won't mess with your $1 and $2 settings.
    Last edited by Tgo01; 07-19-2022 at 09:48 PM.

  9. #29

    Default

    ty for that info, I will surely implement that

  10. #30

    Default

    what if I wanted to loop something every 30 seconds.. like I wanted the gem alert to keep happening every 30 seconds.

    Code:
    while line = get
    	respond " ***  GEM ALERT *** "
    	if line =~ /"dropped"/
    		fput "loot room"
    		break
    	elseif line =~ /YOU HAVE BEEN IDLE TOO LONG./
    		fput "look"
    	end
    end
    
    fput "go turn those bad boys in"

Tags for this Thread

Posting Permissions

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