Tgo01
01-08-2015, 07:41 PM
Here is the code I'm working with:
check_for_boxes = proc {
action = proc { |server_string|
if server_string =~ /^\s{6}(an?|the|some)|^\s{2}(an?|the|some)|^You are currently wearing and carrying\:/
nil
elsif server_string =~ /^\(\d+ items? displayed\.\)/
DownstreamHook.remove("#{script.name}_check_for_boxes")
nil
else
server_string
end
}
DownstreamHook.add("#{script.name}_check_for_boxes", action)
silence_me
fput "inv full"
silence_me
}
check_for_boxes.call
I want it to not send anything to the game window after it sends the "inv full" command.
It works great except for any item that starts with the word "some." It seems to not match any word that begins with some but here are some examples:
some blue lapis lazuli
some fine opaline dust
I really don't understand why it's matching words beginning with "a" and "an" but not "some." I tried doing:
if server_string =~ /^\s{6}some|^\s{2}some|^You are currently wearing and carrying\:/
But still nothing. I even tried:
if server_string =~ /^\s*some|^You are currently wearing and carrying\:/
But still didn't match words starting with some. I even tried getting rid of the carrots in the above examples but still didn't work.
Doing this worked:
if server_string =~ /^.*(an?|the|some)|^You are currently wearing and carrying\:/
But I would prefer not to use something so vague.
I'm sure it's something obvious that I'm missing :/
check_for_boxes = proc {
action = proc { |server_string|
if server_string =~ /^\s{6}(an?|the|some)|^\s{2}(an?|the|some)|^You are currently wearing and carrying\:/
nil
elsif server_string =~ /^\(\d+ items? displayed\.\)/
DownstreamHook.remove("#{script.name}_check_for_boxes")
nil
else
server_string
end
}
DownstreamHook.add("#{script.name}_check_for_boxes", action)
silence_me
fput "inv full"
silence_me
}
check_for_boxes.call
I want it to not send anything to the game window after it sends the "inv full" command.
It works great except for any item that starts with the word "some." It seems to not match any word that begins with some but here are some examples:
some blue lapis lazuli
some fine opaline dust
I really don't understand why it's matching words beginning with "a" and "an" but not "some." I tried doing:
if server_string =~ /^\s{6}some|^\s{2}some|^You are currently wearing and carrying\:/
But still nothing. I even tried:
if server_string =~ /^\s*some|^You are currently wearing and carrying\:/
But still didn't match words starting with some. I even tried getting rid of the carrots in the above examples but still didn't work.
Doing this worked:
if server_string =~ /^.*(an?|the|some)|^You are currently wearing and carrying\:/
But I would prefer not to use something so vague.
I'm sure it's something obvious that I'm missing :/