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...
Printable View
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...
[Secret Hidehout - ]
You notice a massive pile of gems.
Obvious exits: none
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 :p
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.
ty for that info, I will surely implement that
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"