View Full Version : my script questions
onurb
07-18-2022, 07:00 PM
Just going to keep an on going thread for myself here instead of making a thread every time I have a question. I'll end up filling up the forums!
My next question is...
I want to kill a script, but it could be any one of these scripts:
big_apple.lic
red_apple.lic
small_apple.lic
Is there a wild card character I can use to circumvent having to type in every script?
if Script.running?("$_apple")
kill_script("$_apple")
end
I am sure this isnt the correct characters to use, but do you see what I am saying?
Thanks for all the help so far...
Tgo01
07-18-2022, 07:28 PM
Just going to keep an on going thread for myself here instead of making a thread every time I have a question. I'll end up filling up the forums!
My next question is...
I want to kill a script, but it could be any one of these scripts:
big_apple.lic
red_apple.lic
small_apple.lic
Is there a wild card character I can use to circumvent having to type in every script?
if Script.running?("$_apple")
kill_script("$_apple")
end
I am sure this isnt the correct characters to use, but do you see what I am saying?
Thanks for all the help so far...
If you mean you want to kill those scripts if they are running you could do this:
all_scripts = [ "big_apple", "red_apple", "small_apple" ]
all_scripts.each{ |script_name| kill_script script_name }
That would kill each listed script.
onurb
07-18-2022, 08:00 PM
Well thats some good info, and I will definately make use of that. However, the examples I gave you was just 3 script names. What if it was 100 script names? Not saying that it is. But is there not a way that you can do something like anything that ends in _apple will be killed?
Tgo01
07-18-2022, 08:35 PM
Well thats some good info, and I will definately make use of that. However, the examples I gave you was just 3 script names. What if it was 100 script names? Not saying that it is. But is there not a way that you can do something like anything that ends in _apple will be killed?
Script.running.each{ |running_script| kill_script running_script if running_script.name =~ /.*_apple/ }
onurb
07-18-2022, 09:56 PM
Thank you, that worked out just as I needed it to. I knew * meant everything but didnt realize it was in lich/ruby also.
So I got this problem now...
I am trying to get a heirloom out of my container and the command below usually works, but sometimes the critter I killed will carry the item I need but its not classified as "jewelry".
do_client(";foreach first 1 jewelry in knapsack;get item")
So I started using this, and it was working for a while, atleast until the last critter I killed carried a box, a gem, and the heirloom. When I looted them, the gem ended up being the first item in my container and therfor, was pulled out with the command below.
do_client(";foreach first 1 unique in knapsack;get item")
What can I do to fix this?
Tgo01
07-18-2022, 10:39 PM
Thank you, that worked out just as I needed it to. I knew * meant everything but didnt realize it was in lich/ruby also.
So I got this problem now...
I am trying to get a heirloom out of my container and the command below usually works, but sometimes the critter I killed will carry the item I need but its not classified as "jewelry".
do_client(";foreach first 1 jewelry in knapsack;get item")
So I started using this, and it was working for a while, atleast until the last critter I killed carried a box, a gem, and the heirloom. When I looted them, the gem ended up being the first item in my container and therfor, was pulled out with the command below.
do_client(";foreach first 1 unique in knapsack;get item")
What can I do to fix this?
I'm not sure about using the ;foreach script, I have never used it before.
This bit of code should work for you though:
if checkbounty =~ /You have located (?:an?|some) (.*) and should bring it back/
heirloom_name = $1
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
needed_item = container.contents.find{ |item| item.name =~ /#{heirloom_name}/ }
fput "get ##{needed_item.id}"
end
onurb
07-19-2022, 09:56 AM
that works well, ty. what does $1 mean
Slark
07-19-2022, 12:18 PM
$ in this context means a regex match. In the previous line, (.*) sets up a regex group, and you match against that using the =~ syntax. You can run each of these from the client in game to see what they do:
;e foo=/(.*) (.*)/;"hello world"=~foo;echo $1
;e foo=/(.*) (.*)/;"hello world"=~foo;echo $2
;e foo=/(.*)/;"hello world"=~foo;echo $1
Just to be clear, the 1 in $1 means the first regex match. $2 is the second one, etc.
onurb
07-19-2022, 12:34 PM
$ in this context means a regex match. In the previous line, (.*) sets up a regex group, and you match against that using the =~ syntax. You can run each of these from the client in game to see what they do. Just to be clear, the 1 in $1 means the first regex match. $2 is the second one, etc.
hmm, thats very cool. ty for the explanation. this will come in handy.
onurb
07-19-2022, 12:37 PM
trying to adjust the code to accomodate gems, but it appears I may have something wrong...
if checkbounty =~ /multiple customers requesting (?:an?|some) (.*)/
gem_name = $1
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
needed_gem = container.contents.find{ |item| item.name =~ /#{gem_name}/ }
fput "get ##{needed_gem.id}"
end
output is this...
>;test
--- Lich: test active.
[test]>get #
Get what?
--- Lich: test has exited.
onurb
07-19-2022, 01:20 PM
disregard the above, I figured it out. didnt put the captured text from the game in properly.
onurb
07-19-2022, 01:25 PM
another quick question..
so the gem I grabbed from my knapsack was id #1302200900
does this mean that gem will always have that id in the game. if I find another one of the same type will it have the same id?
Tgo01
07-19-2022, 02:21 PM
another quick question..
so the gem I grabbed from my knapsack was id #1302200900
does this mean that gem will always have that id in the game. if I find another one of the same type will it have the same id?
No. Every noun in the game has their own unique ID number, and this ID number can change even for the same item (usually when you log out or put items in your locker.)
onurb
07-19-2022, 03:03 PM
while line = get
if line =~ /"need (.*) (.*)"/
gem_quantity = $1
gem_name = $2
fput "say #{gem_quantity} #{gem_name}"
do_client(";foreach first #{gem_quantity} name=#{gem_name}/ in knapsack;get item;drop item");
end
end
seems the fput is working, but the regex in the ;foreach command dosent seem to be working. the fput is more of a test, will be taken out when the line below it starts working
Tgo01
07-19-2022, 03:17 PM
while line = get
if line =~ /"need (.*) (.*)"/
gem_quantity = $1
gem_name = $2
fput "say #{gem_quantity} #{gem_name}"
do_client(";foreach first #{gem_quantity} name=#{gem_name}/ in knapsack;get item;drop item");
end
end
seems the fput is working, but the regex in the ;foreach command dosent seem to be working. the fput is more of a test, will be taken out when the line below it starts working
I don't know anything about ;foreach so I'm not sure where the hangup is.
onurb
07-19-2022, 03:22 PM
I don't really think its a foreach thing moreso a "how do you a regex as a variable in a command for starting another script" thing
it could be any script..
onurb
07-19-2022, 03:24 PM
basically I am trying to get $2 from my knapsack and drop it and repeat this a $1 amount of times
Tgo01
07-19-2022, 03:30 PM
do_client(";foreach first #{gem_quantity} name=#{gem_name}/ in knapsack;get item;drop item")
I'm not sure what is ;foreach related. I'm assuming you don't need name=#{gem_name} and it instead should just be #{gem_name}, but I'm not sure if the name= is part of running ;foreach :p
Also I think ;foreach wouldn't work with full names? Like "get my blue coral" would work, but "get my polished blue coral" would not work because the game only recognizes when you use an adjective and a noun, so if gem_name is the full name of a gem it might not work in all instances.
Tgo01
07-19-2022, 03:45 PM
basically I am trying to get $2 from my knapsack and drop it and repeat this a $1 amount of times
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
onurb
07-19-2022, 07:29 PM
--- 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"
Lavastene
07-19-2022, 07:37 PM
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...
onurb
07-19-2022, 07:59 PM
[Secret Hidehout - ]
You notice a massive pile of gems.
Obvious exits: none
Tgo01
07-19-2022, 08:59 PM
--- 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.
Lavastene
07-19-2022, 09:06 PM
--- 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.
onurb
07-19-2022, 09:17 PM
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 (.*)
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
Tgo01
07-19-2022, 09:20 PM
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 (.*)
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
onurb
07-19-2022, 09:33 PM
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
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
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.
Tgo01
07-19-2022, 09:44 PM
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.
onurb
07-19-2022, 09:49 PM
ty for that info, I will surely implement that
onurb
07-19-2022, 10:46 PM
what if I wanted to loop something every 30 seconds.. like I wanted the gem alert to keep happening every 30 seconds.
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"
Tgo01
07-19-2022, 11:03 PM
what if I wanted to loop something every 30 seconds.. like I wanted the gem alert to keep happening every 30 seconds.
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"
Do you just want the GEM ALERT every 30 seconds? Or the whole while statement?
You can wrap the whole thing in a loop.
loop{
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"
sleep 30
}
I'm also assuming you want the GEM ALERT to be within the first if statement, otherwise it's going to echo that after every line.
onurb
07-19-2022, 11:18 PM
Do you just want the GEM ALERT every 30 seconds? Or the whole while statement?
was wanting the gem alert message every 30 seconds while its waiting for those two matches "dropped" or "idle too long" to occur.
Tgo01
07-19-2022, 11:28 PM
Probably easiest to just run a new thread.
Thread.new
loop{
respond " *** GEM ALERT *** "
sleep 30
}
}
while line = get
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"
A new thread basically just runs a set of code separately from the other code in the script. Careful when using a thread though because each thread and the main code share the game lines coming in, meaning if you have a thread/the main code both looking for game lines (such as a while line loop and using an fput) then one of them isn't going to see all of the game lines.
It's fine otherwise for code that isn't looking at game lines, which respond does not.
onurb
07-20-2022, 01:30 AM
I am on the brink of putting this all together (thanks to you, and some others), but I seem to have one last error to iron out...
while line = get
if line =~ /(?:Bill|Bob|Ted) says, "(.*): (.*)"/
gem_quantity = $1
gem_name = $2
gem_quantity.times{
fput "get #{gem_name} from my knapsack"
fput "drop #{gem_name}"
}
fput "There you go!"
end
end
For some reason it dosen't understand how many times it's supposed to drop a gem. If I put an actual number in there like this "10.times" instead of "gem_quantity.times" it will work like a charm. I would also really like to figure out a way to not have to put a character between the two (.*): (.*) just to make it work. if you take out that semi colon, the first regex merges with the second regex even if there is a space between them. But if that cant be, not too worried about it.
--- Lich: error: undefined method `times' for "10":String
dropgem:6:in `_script'
C:/Lich5/lich.rbw:802:in `eval'
Tgo01
07-20-2022, 01:55 AM
I am on the brink of putting this all together (thanks to you, and some others), but I seem to have one last error to iron out...
while line = get
if line =~ /(?:Bill|Bob|Ted) says, "(.*): (.*)"/
gem_quantity = $1
gem_name = $2
gem_quantity.times{
fput "get #{gem_name} from my knapsack"
fput "drop #{gem_name}"
}
fput "There you go!"
end
end
For some reason it dosen't understand how many times it's supposed to drop a gem. If I put an actual number in there like this "10.times" instead of "gem_quantity.times" it will work like a charm. I would also really like to figure out a way to not have to put a character between the two (.*): (.*) just to make it work. if you take out that semi colon, the first regex merges with the second regex even if there is a space between them. But if that cant be, not too worried about it.
--- Lich: error: undefined method `times' for "10":String
dropgem:6:in `_script'
C:/Lich5/lich.rbw:802:in `eval'
By default regex sees things as strings/characters, even though it is a digit, so it doesn't see the number 2 as a number, it sees it as a character just as if it were the letter "a".
So you would need to do: gem_quantity = $1.to_i
This would make it store the value as an integer.
As far as the space issue you could do:
(?:Bill|Bob|Ted) says, "(\d+) (.*)"
\d means any digit and + just 1 or more, so that should work.
onurb
07-20-2022, 02:38 AM
https://y.yarn.co/92dc46e8-a664-42a1-a01e-34b12ae77bff_text.gif
I'll be back tomorrow. Need to figure out how to keep them from saying "There you go!" if they don't have the gems needed.
onurb
07-21-2022, 01:17 AM
seems I have run into an issue
if checkbounty =~ /The gem dealer in Ta'Illistim, Tanzania, has received orders from multiple customers requesting (?:an?|some|piece|of) (.*). You have been tasked to retrieve (.*) of them./
gem_name = $1
gem_quantity = $2.to_i
gem_quantity.times{
fput "get my #{gem_name}"
fput "sell my #{gem_name}"
}
end
[sellgem]>get my green malachite stone
Get what?
>
[sellgem]>sell my green malachite stone
What were you referring to?
Is there a way to ignore everything between "requesting" and the gem's noun? I think it would be too difficult to try and determine the adjective of the noun as sometimes its the first word in a 3 word gem, sometimes its the second word...
Tgo01
07-21-2022, 01:25 AM
seems I have run into an issue
if checkbounty =~ /The gem dealer in Ta'Illistim, Tanzania, has received orders from multiple customers requesting (?:an?|some|piece|of) (.*). You have been tasked to retrieve (.*) of them./
gem_name = $1
gem_quantity = $2.to_i
gem_quantity.times{
fput "get my #{gem_name}"
fput "sell my #{gem_name}"
}
end
[sellgem]>get my green malachite stone
Get what?
>
[sellgem]>sell my green malachite stone
What were you referring to?
Is there a way to ignore everything between "requesting" and the gem's noun? I think it would be too difficult to try and determine the adjective of the noun as sometimes its the first word in a 3 word gem, sometimes its the second word...
Easiest way would probably be to use the code I posted earlier about looking through your knapsack container and getting the item ID number. That way it can match the whole name of the gem in your container and get the item ID so you don't have to worry about the wording.
onurb
07-21-2022, 12:55 PM
so I did that, and it seems like its using ids now instead of names. but it wants to use the same id every time...
if checkbounty =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between|under) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb_name = $1
herb_location = $2
herb_quantity = $3.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
herb_quantity.times{
fput "get my ##{needed_item.id}"
fput "give my ##{needed_item.id} to jhiseth"
}
end
>;test
--- Lich: test active.
[test]>get my #1325423487
Get what?
>
[test]>give my #1325423487 to jhiseth
What is it you're trying to give?
>
[test]>get my #1325423487
Get what?
>
[test]>give my #1325423487 to jhiseth
What is it you're trying to give?
>
--- Lich: test has exited.
alaricthenoble
07-21-2022, 02:06 PM
so I did that, and it seems like its using ids now instead of names. but it wants to use the same id every time...
if checkbounty =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between|under) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb_name = $1
herb_location = $2
herb_quantity = $3.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
herb_quantity.times{
fput "get my ##{needed_item.id}"
fput "give my ##{needed_item.id} to jhiseth"
}
end
>;test
--- Lich: test active.
[test]>get my #1325423487
Get what?
>
[test]>give my #1325423487 to jhiseth
What is it you're trying to give?
>
[test]>get my #1325423487
Get what?
>
[test]>give my #1325423487 to jhiseth
What is it you're trying to give?
>
--- Lich: test has exited.
I'm ultimately not familiar with the methods and nuances of Lich's exposed methods, and I haven't really written Ruby since Ruby on Rails was the hot thing, so I can point you towards "what is happening" here but can't quite edge you towards a solid resolution without some research.
Your ".times" method is creating a loop (https://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm) but you're updating the ID before you enter the loop on the line above it.
If you want the ID to be different for each iteration you need to update it again inside the loop.
onurb
07-21-2022, 02:59 PM
If you want the ID to be different for each iteration you need to update it again inside the loop.
I had thought about that as well and I did try to put the id line inside of the loop like this, but it produced the same result.
if checkbounty =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between|under) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb_name = $1
herb_location = $2
herb_quantity = $3.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
herb_quantity.times{
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
fput "get my ##{needed_item.id}"
fput "give my ##{needed_item.id} to jhiseth"
}
end
no luck
Tgo01
07-21-2022, 03:03 PM
I had thought about that as well and I did try to put the id line inside of the loop like this, but it produced the same result.
if checkbounty =~ /concoction that requires (?:a |an )?(.*) found (?:on |in )?(.*?)(?: (?:near|between|under) .*?)?\.\s+These samples must be in pristine condition\.\s+You have been tasked to retrieve (\d+) (?:more )?sample/
herb_name = $1
herb_location = $2
herb_quantity = $3.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
herb_quantity.times{
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
fput "get my ##{needed_item.id}"
fput "give my ##{needed_item.id} to jhiseth"
}
end
no luck
When using an item ID be sure not use MY, that will mess things up.
Try this same code again but without my.
onurb
07-21-2022, 07:07 PM
Alright, finally got this one working flawlessly so far. This part here is very touchy (?:a |an |some|piece of). It can change alot depending on the town your in and the type of gems available. So far its working with the gem types I have. Did I do that right with the |piece of) or should it be |piece|of)? Waiting for another herb quest to test out the other script.
if checkbounty =~ /The gem dealer in Ta'Illistim, Tanzania, has received orders from multiple customers requesting (?:a |an |some|piece of)?(.*). You have been tasked to retrieve (.*) of them./
gem_name = $1
gem_quantity = $2.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
gem_quantity.times{
needed_item = container.contents.find{ |item| item.name =~ /#{gem_name}/ }
fput "get ##{needed_item.id}"
fput "sell ##{needed_item.id}"
}
end
Tgo01
07-21-2022, 08:57 PM
ADid I do that right with the |piece of) or should it be |piece|of)?
|piece of) should be correct.
Glad it's working for you now. Woot!
onurb
07-21-2022, 09:53 PM
Finally got an herb task, and cant seem to get it to work. The bounty string is much more complicated. Pretty sure everything below that is correct though.
if checkbounty =~ /concoction that requires (?:a |an |some|sprig of|stalk of)?(.*) found (?:in|on|the) Yegharren Plains(?:near|Ta'Illistim). These samples must be in pristine condition. You have been tasked to retrieve (.*) samples./
herb_name = $1
herb_quantity = $2.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
herb_quantity.times{
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
fput "get ##{needed_item.id}"
fput "give ##{needed_item.id} to jhiseth"
}
end
The bounty strings can look like either of these...
The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a small turnip found in Old Ta'Faendryl. These samples must be in pristine condition. You have been tasked to retrieve 6 samples.
The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a wild strawberry found on the Yegharren Plains near Ta'Illistim. These samples must be in pristine condition. You have been tasked to retrieve 9 samples.
I tried to guess at how to omit the " near Ta'Illistim" part, looks like I got it wrong. Is there a way to omit a bunch of text in the bounty string thats not important and also changes? or can you do two sections /yada yada yada (.*)/ + /yada yada yada (.*)/ somethin like that?
Tgo01
07-21-2022, 10:08 PM
Finally got an herb task, and cant seem to get it to work. The bounty string is much more complicated. Pretty sure everything below that is correct though.
if checkbounty =~ /concoction that requires (?:a |an |some|sprig of|stalk of)?(.*) found (?:in|on|the) Yegharren Plains(?:near|Ta'Illistim). These samples must be in pristine condition. You have been tasked to retrieve (.*) samples./
herb_name = $1
herb_quantity = $2.to_i
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
herb_quantity.times{
needed_item = container.contents.find{ |item| item.name =~ /#{herb_name}/ }
fput "get ##{needed_item.id}"
fput "give ##{needed_item.id} to jhiseth"
}
end
The bounty strings can look like either of these...
The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a small turnip found in Old Ta'Faendryl. These samples must be in pristine condition. You have been tasked to retrieve 6 samples.
The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a wild strawberry found on the Yegharren Plains near Ta'Illistim. These samples must be in pristine condition. You have been tasked to retrieve 9 samples.
I tried to guess at how to omit the " near Ta'Illistim" part, looks like I got it wrong. Is there a way to omit a bunch of text in the bounty string thats not important and also changes? or can you do two sections /yada yada yada (.*)/ + /yada yada yada (.*)/ somethin like that?
Yeah you can use .* to match most of the unnecessary information.
if checkbounty =~ /concoction that requires (?:a |an |some|sprig of|stalk of)?(.*) found .* You have been tasked to retrieve (.*) samples./
onurb
07-21-2022, 10:21 PM
wonderful, I got this working now I think.
btw I had to put a ? on each side of that .* you put or it would not work.
Tgo01
07-21-2022, 10:38 PM
btw I had to put a ? on each side of that .* you put or it would not work.
Weird. As long as it's working.
onurb
07-24-2022, 11:22 AM
Question...
so in the script you helped me with, the "checkbounty" apparenly knows to check the active bounty task string. how does it know that? is this a built in word in lich? because I looked on the lich scripting reference and did not see any mention of checkbounty. is there a list somewhere that shows what checkwords are attached to what strings? whats the proper terminology for those words btw?
Tgo01
07-24-2022, 02:34 PM
Question...
so in the script you helped me with, the "checkbounty" apparenly knows to check the active bounty task string. how does it know that? is this a built in word in lich? because I looked on the lich scripting reference and did not see any mention of checkbounty. is there a list somewhere that shows what checkwords are attached to what strings? whats the proper terminology for those words btw?
I think the information gets sent to the FE because SF has a bounty window that updates with your current bounty information and Lich reads this information. I know there is a list of some commands on the Wiki but not sure it's an exhaustive list.
onurb
07-24-2022, 07:47 PM
Trying to hold each person in the room and make them apart of the group...
person = GameObj.pcs.find { |pcs| pcs.status.nil? }
person.times{
if person
fput "hold ##{person.id}"
end
}
am I on the right track here?
Tgo01
07-24-2022, 07:50 PM
Trying to hold each person in the room and make them apart of the group...
person = GameObj.pcs.find { |pcs| pcs.status.nil? }
person.times{
if person
fput "hold ##{person.id}"
end
}
am I on the right track here?
GameObj.pcs.each{ |pc| fput "hold ##{pc.id}" }
onurb
07-24-2022, 11:18 PM
is there a speed thats between 0 and sleep 1, does it handle decimals
seems sometimes when I am selling gems or herbs, if I have a high number like quantity of 9, it goes too fast and ends up ending with 2 gems left to sell
maybe I could just throw a waitfor in there
Tgo01
07-24-2022, 11:26 PM
is there a speed thats between 0 and sleep 1, does it handle decimals
seems sometimes when I am selling gems or herbs, if I have a high number like quantity of 9, it goes too fast and ends up ending with 2 gems left to sell
maybe I could just throw a waitfor in there
You can do sleep 0.1
Also you can wait until the gem is in your hand by doing:
wait_until{ checkright }
And then wait until the gem is no longer in your hand by doing:
wait_until { checkright.nil? }
onurb
07-26-2022, 09:46 PM
what if the items were on the ground and not in my knapsack, how would that change these?
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
needed_item = container.contents.find{ |item| item.name =~ /#
Tgo01
07-26-2022, 09:56 PM
needed_item = GameObj.loot.find{ |item| item.name =~ /stuff/ }
onurb
07-26-2022, 10:05 PM
well, its working, however, its picking a gem up, putting it in my knapsack, and then getting it back out of the knapsack and putting it back in
if checkbounty =~ /Tanzania, has received orders from multiple customers requesting (?:a |an |some|piece of|shard of)?(.*). You have been tasked to retrieve (\d+)?.*?of them/
gem_name = $1
gem_quantity = $2.to_i
needed_item = GameObj.loot.find{ |item| item.name =~ /#{gem_name}/ }
gem_quantity.times{
fput "get ##{needed_item.id}"
fput "put ##{needed_item.id} in my knapsack"
}
Tgo01
07-26-2022, 10:09 PM
if checkbounty =~ /Tanzania, has received orders from multiple customers requesting (?:a |an |some|piece of|shard of)?(.*). You have been tasked to retrieve (\d+)?.*?of them/
gem_name = $1
gem_quantity = $2.to_i
gem_quantity.times{
needed_item = GameObj.loot.find{ |item| item.name =~ /#{gem_name}/ }
fput "get ##{needed_item.id}"
fput "put ##{needed_item.id} in my knapsack"
}
onurb
08-22-2022, 07:02 PM
Was just looking through the lich scripting reference and saw an example I could make use of. So I went to test it...
dothistimeout
dothistimeout "action here", time, "string to match for success"
I just did something simple...
dothistimeout "fame", "10", "You feel more refreshed."
fput "smile"
I figured it would do the fame verb and then in 10 seconds if it did not see "You feel more refreshed." it would move onto the next line and smile.
Well here is what I got...
>;test
--- Lich: test active.
--- Lich: error: String can't be coerced into Float
C:/Lich5/lib/global_defs.rb:1802:in `+'
C:/Lich5/lib/global_defs.rb:1802:in `dothistimeout'
--- Lich: test has exited.
what am I doing wrong here? I literally copied and pasted it directly from the lich guide.
Tgo01
08-22-2022, 07:05 PM
Was just looking through the lich scripting reference and saw an example I could make use of. So I went to test it...
dothistimeout
dothistimeout "action here", time, "string to match for success"
I just did something simple...
dothistimeout "fame", "10", "You feel more refreshed."
fput "smile"
I figured it would do the fame verb and then in 10 seconds if it did not see "You feel more refreshed." it would move onto the next line and smile.
Well here is what I got...
>;test
--- Lich: test active.
--- Lich: error: String can't be coerced into Float
C:/Lich5/lib/global_defs.rb:1802:in `+'
C:/Lich5/lib/global_defs.rb:1802:in `dothistimeout'
--- Lich: test has exited.
what am I doing wrong here? I literally copied and pasted it directly from the lich guide.
It would be:
dothistimeout "fame", 10, "You feel more refreshed."
I'm assuming you can use a string, I've always used regexes.
onurb
08-22-2022, 07:09 PM
I actually did try it out first without the quotes on the 10, that didnt work either, this is what I got..
>;test
--- Lich: test active.
[test]>fame
Your personal fame is 43,458.
You are a level 1 Human Monk.
>
--- Lich: error: type mismatch: String given
C:/Lich5/lib/global_defs.rb:1811:in `=~'
C:/Lich5/lib/global_defs.rb:1811:in `block (2 levels) in dothistimeout'
--- Lich: test has exited.
Tgo01
08-22-2022, 07:22 PM
I actually did try it out first without the quotes on the 10, that didnt work either, this is what I got..
>;test
--- Lich: test active.
[test]>fame
Your personal fame is 43,458.
You are a level 1 Human Monk.
>
--- Lich: error: type mismatch: String given
C:/Lich5/lib/global_defs.rb:1811:in `=~'
C:/Lich5/lib/global_defs.rb:1811:in `block (2 levels) in dothistimeout'
--- Lich: test has exited.
So it probably does have to be a regex.
dothistimeout "fame", 10, /You feel more refreshed./
onurb
08-22-2022, 07:26 PM
indeed that worked. ty
wonder why the lich guide has " " instead of / /
onurb
09-16-2022, 09:58 PM
Trying to make a simple heirloom search script...
if checkbounty =~ /in (?:the) (.*) (?:in|near) (.*). The heirloom can be identified by the initials/
location_name = $1
end
if location_name == "Gossamer Valley"
start_script("go2", [ "1749" ])
wait_while { Script.running?("go2") };
elsif location_name == "Blighted Forest"
start_script("go2", [ "9697" ])
wait_while { Script.running?("go2") };
elsif location_name == "Griffin's Keen"
start_script("go2", [ "3980" ])
wait_while { Script.running?("go2") };
elsif location_name == "Temple Wyneb"
start_script("go2", [ "110" ])
wait_while { Script.running?("go2") };
elsif location_name == "Old Ta'Faendryl"
start_script("go2", [ "12016" ])
wait_while { Script.running?("go2") };
end
start_script("spellactive")
if Spell[213].known? and Spell[213].affordable?
Spell[213].cast
fput "stance defensive", "kneel", "search"
if checkbounty =~ /and should bring it back to one of the guardsmen/
fput "loot room"
break
end
end
where I am having an issue is, how do give the script a set of directions in which to crawl to the next room if no heirloom is found. I figure I have to loop that last part and then it will rotate through each of my directions (n,s,e,w, etc). I am picking areas where I can just keep crawling in a circle, like 4 rooms, so I want the directions to repeat if no heirloom found.
$direction = ["n", "e", "s", "w"]
this kind of thing ^
Tgo01
09-16-2022, 10:19 PM
if checkbounty =~ /in (?:the) (.*) (?:in|near) (.*). The heirloom can be identified by the initials/
location_name = $1
end
if location_name == "Gossamer Valley"
start_script("go2", [ "1749" ])
wait_while { Script.running?("go2") };
elsif location_name == "Blighted Forest"
start_script("go2", [ "9697" ])
wait_while { Script.running?("go2") };
elsif location_name == "Griffin's Keen"
start_script("go2", [ "3980" ])
wait_while { Script.running?("go2") };
elsif location_name == "Temple Wyneb"
start_script("go2", [ "110" ])
wait_while { Script.running?("go2") };
elsif location_name == "Old Ta'Faendryl"
start_script("go2", [ "12016" ])
wait_while { Script.running?("go2") };
end
start_script("spellactive")
direction = ["n", "e", "s", "w"]
number = 0
loop{
if Spell[213].known? and Spell[213].affordable?
Spell[213].cast
fput "stance defensive", "kneel", "search"
if checkbounty =~ /and should bring it back to one of the guardsmen/
fput "loot room"
break
else
until standing?
waitrt?
fput "stand"
sleep 0.2
end
move direction[number]
end
end
number += 1
number = 0 if number >= direction.count
}
onurb
09-16-2022, 10:34 PM
Can I put this part here...
direction = ["n", "e", "s", "w"]
number = 0
into the location section of the script and adjust it's directions for each location? or must that part be right on top of the loop?
Tgo01
09-16-2022, 10:39 PM
Can I put this part here...
direction = ["n", "e", "s", "w"]
number = 0
into the location section of the script and adjust it's directions for each location? or must that part be right on top of the loop?
It can be wherever.
Really no point in repeating the number = 0 line though, that just needs to be defined once before the loop.
onurb
09-17-2022, 12:12 AM
It can be wherever.
Really no point in repeating the number = 0 line though, that just needs to be defined once before the loop.
It's all workin good, thanks a bunch.
Tgo01
09-17-2022, 12:13 AM
It's all workin good, thanks a bunch.
You betcha.
onurb
09-17-2022, 02:20 PM
Ran into an issue, all location_names work except for Griffin's Keen. I think the apostrophe in Griffin's is screwing up the regex. Maybe it has to be one of those fancy regexes, I tried looking them up but there are so many and they are so confusing.
if checkbounty =~ /in (?:the )?(.*) (?:in|near) (.*). The heirloom can be identified by the initials/
location_name = $1
end
if location_name == "Gossamer Valley"
start_script("go2", [ "1749" ])
wait_while { Script.running?("go2") };
direction = ["n", "ne", "ne", "se", "e", "sw", "sw", "w", "w"]
elsif location_name == "Blighted Forest"
start_script("go2", [ "9693" ])
wait_while { Script.running?("go2") };
direction = ["w", "w", "w", "nw", "e", "s", "e", "e", "n", "se"]
elsif location_name == "Griffin's Keen"
start_script("go2", [ "3980" ])
wait_while { Script.running?("go2") };
direction = ["e", "e", "e", "e", "e", "w", "w", "w", "w", "w"]
elsif location_name == "Temple Wyneb"
start_script("go2", [ "110" ])
wait_while { Script.running?("go2") };
direction = ["ne", "ne", "ne", "ne", "e", "e", "e", "e", "e", "se", "se", "se", "se", "s", "s", "s", "s", "sw", "sw", "sw", "s", "s", "sw", "w", "w", "w", "w", "w", "nw", "n", "n", "nw", "nw", "nw", "n", "n", "n"]
elsif location_name == "Old Ta'Faendryl"
start_script("go2", [ "12016" ])
wait_while { Script.running?("go2") };
direction = ["n", "ne", "se", "s", "sw", "nw"]
end
for reference, the bounty task word for word is..
You have been tasked to recover a brushed steel hair pin that an unfortunate citizen lost after being attacked by a lesser griffin in Griffin's Keen near Ta'Illistim. The heirloom can be identified by the initials SE engraved upon it. SEARCH the area until you find it.
Tgo01
09-17-2022, 02:40 PM
It's because the heirloom is a pIN which is matching "in" much earlier than you want so the entire first group is "that an unfortunate citizen lost after being attacked by a lesser griffin in Griffin's Keen"
This is a great website to use when you're having trouble with a regex: https://rubular.com/
Just enter your regex and the line you are matching and it will show you if it is matching correctly and which groups are being matched and all that good stuff.
onurb
09-27-2022, 10:06 PM
Am I doing this right here? the original was working good until I came across critters that drag you to another room...
original
if Char.prof == "Cleric"
loop{
if Spell[213].known? and Spell[213].affordable?
Spell[213].cast and waitcastrt?
fput "stance defensive", "You are now in a defensive stance."
fput "kneel"
fput "search"
sleep 1
if checkbounty =~ /and should bring it back to one of the guardsmen/
waitrt?
sleep 1
fput "loot room"
break
else
until standing?
waitrt?
fput "stand"
waitrt?
sleep 0.2
end
move direction[number]
end
end
number += 1
number = 0 if number >= direction.count
}
elsif Char.prof == "Empath"
yada yada yada....
updated version incase a critter drags me to another room. also, is there a command to tell the script to start over? or start from the beginning again?
if Char.prof == "Cleric"
loop{
if Spell[213].known? and Spell[213].affordable?
Spell[213].cast and waitcastrt?
fput "stance defensive", "You are now in a defensive stance."
fput "kneel"
fput "search"
if line =~ /You intently search the area for the heirloom/
sleep 1
if checkbounty =~ /and should bring it back to one of the guardsmen/
waitrt?
sleep 1
fput "loot room"
break
else
until standing?
waitrt?
fput "stand"
waitrt?
sleep 0.2
end
move direction[number]
end
elsif line =~ /You don't find anything of interest here/
waitrt?
(start script over)
end
end
number += 1
number = 0 if number >= direction.count
}
Tgo01
09-27-2022, 10:09 PM
if Char.prof == "Cleric"
loop{
if Spell[213].known? and Spell[213].affordable?
Spell[213].cast
fput "stance defensive"
fput "kneel"
fput "search"
while line = get
if line =~ /You intently search the area for the heirloom/
sleep 1
if checkbounty =~ /and should bring it back to one of the guardsmen/
waitrt?
sleep 1
fput "loot room"
break
else
until standing?
waitrt?
fput "stand"
waitrt?
sleep 0.2
end
move direction[number]
end
elsif line =~ /You don't find anything of interest here/
waitrt?
end
end
end
number += 1
number = 0 if number >= direction.count
}
I don't know exactly what you mean by starting the script over again.
onurb
09-27-2022, 10:21 PM
well when you run a script, it starts at line 1, top of the page
is there a way to like dump everything in memory (ex what direction it was going to go next) and start at line 1 again?
Tgo01
09-27-2022, 10:35 PM
You can do a loop and set any variables to nil or 0. So you could set number = 0
Or you can make the entire thing a method or procedure and call it when you need to.
Otherwise I'm not aware of a way for a script to restart itself. The other option would be to have a second script running that looks for a global variable being set to true, then set that global variable to true when you want it to reset. Then the other script will stop the first script and start it again and set the variable to nil and continue looking for when it is set to true.
onurb
09-27-2022, 11:09 PM
I am suprised as complex and diverse as ruby is, it is unable to restart a script.
even the wizard FE code was able to restart..
start:
put "hello
goto start
onurb
09-27-2022, 11:17 PM
Well how about this...
earlier in the script I have this
if location_name == "Graveyard" && critter_name == "skeleton"
start_script("go2", [ "1234" ])
wait_while { Script.running?("go2") };
direction = ["ne", "ne", "s", "sw", "w"]
is there a way I can save that 1234 as a variable to be used below?
elsif line =~ /You don't find anything of interest here/
waitrt?
start_script("go2", [ "????" ])
wait_while { Script.running?("go2") };
number = 0
end
Tgo01
09-27-2022, 11:19 PM
I am suprised as complex and diverse as ruby is, it is unable to restart a script.
even the wizard FE code was able to restart..
start:
put "hello
goto start
You can do something similar to that in Ruby.
You could do:
stuff_to_do = proc{
code here
code here
}
Then whenever you want to call this block of code do: stuff_to_do.call
You could be sure to nil our or zero out all of your variables at the top of the code so everything is starting over fresh if that's what you need.
Tgo01
09-27-2022, 11:20 PM
Well how about this...
earlier in the script I have this
if location_name == "Graveyard" && critter_name == "skeleton"
start_script("go2", [ "1234" ])
wait_while { Script.running?("go2") };
direction = ["ne", "ne", "s", "sw", "w"]
is there a way I can save that 1234 as a variable to be used below?
elsif line =~ /You don't find anything of interest here/
waitrt?
start_script("go2", [ "????" ])
wait_while { Script.running?("go2") };
number = 0
end
Yeah you could set the variable before this code.
So you could do for example:
skeleton_graveyard_room_number = 1234
Then do: start_script("go2", [ skeleton_graveyard_room_number ])
onurb
10-27-2022, 02:03 AM
wracking my brain on this all evening... trying to give armor support to the chars that don't already have it. But I don't want the screen scroll for doing a "spell active" on each char which seems to be working but it's giving armor support to chars that already have it. need help
GameObj.pcs.each{ |pc|
silence_me unless undo_silence = silence_me
line = Lich::Util.quiet_command_xml("spell active #{pc}", /currently has the following active effects/)
if line =~ /Armor Support/
fput "smile"
else
fput "armor support #{pc}"
sleep 5
waitrt?
end
silence_me if undo_silence
}
Tgo01
10-27-2022, 02:23 AM
wracking my brain on this all evening... trying to give armor support to the chars that don't already have it. But I don't want the screen scroll for doing a "spell active" on each char which seems to be working but it's giving armor support to chars that already have it. need help
GameObj.pcs.each{ |pc|
silence_me unless undo_silence = silence_me
line = Lich::Util.quiet_command_xml("spell active #{pc}", /currently has the following active effects/)
if line =~ /Armor Support/
fput "smile"
else
fput "armor support #{pc}"
sleep 5
waitrt?
end
silence_me if undo_silence
}
Util.quiet looks at all lines after it enters the command you specify and until it sees the command prompt.
Try this:
GameObj.pcs.each{ |pc|
silence_me unless undo_silence = silence_me
result = Lich::Util.quiet_command_xml("spell active #{pc}", /currently has the following active effects/)
if result.find{ |line| line =~ /Armor Support/i }
fput "smile"
else
fput "armor support #{pc}"
sleep 5
waitrt?
end
silence_me if undo_silence
}
Rinualdo
10-27-2022, 06:48 AM
armor.rb and waggle when it goes to ewaggle will support armor skills
onurb
10-30-2022, 12:34 AM
why on earth is this thing grabbing a dragon's tear ruby as its first gem when thats not even one of the 3 listed gems.
container = GameObj.inv.find{ |item| item.noun == "#{container1}" }
gem = container.contents.find{ |gem| gem.name =~ /uncut ruby|uncut emerald|uncut diamond/ }
result = String.new
until result =~ /You remove/i
fput "get #{gem} from my #{container1}"
result = matchwait("Get what?","I could not find","You remove")
if result =~ /Get what?/
next
elsif result =~ /I could not find/
next
elsif result =~ /You remove/
break
end
end
Tgo01
10-30-2022, 12:55 AM
why on earth is this thing grabbing a dragon's tear ruby as its first gem when thats not even one of the 3 listed gems.
container = GameObj.inv.find{ |item| item.noun == "#{container1}" }
gem = container.contents.find{ |gem| gem.name =~ /uncut ruby|uncut emerald|uncut diamond/ }
result = String.new
until result =~ /You remove/i
fput "get #{gem} from my #{container1}"
result = matchwait("Get what?","I could not find","You remove")
if result =~ /Get what?/
next
elsif result =~ /I could not find/
next
elsif result =~ /You remove/
break
end
end
The script is probably just doing "get ruby". Try just doing: fput "get ##{gem.id}"
When using ids you don't want to use "my" or the name of the container or anything.
onurb
10-30-2022, 01:39 AM
thank you, thats working nice now, except..... when I get done with all 3 gems it starts doing...
[test]>get # from my pouch
Get what?
[test]>get # from my pouch
Get what?
[test]>get # from my pouch
Get what?
onurb
10-30-2022, 01:52 AM
cancel that, had a "next" instead of an "exit"
onurb
11-04-2022, 07:58 PM
Am I close? I am trying to get each piece of clothing inside of my knapsack and drop them on the ground
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
clothing = container.contents.find{ |item| item.type == "clothing" }
clothing.each{
multifput "get my ##{clothing.id} from my ##{container.id}", "drop my ##{clothing.id}"
}
Tgo01
11-04-2022, 08:04 PM
container = GameObj.inv.find{ |item| item.noun == "knapsack" }
fput "look in ##{container.id}"
sleep 1
container.contents.each{ |item|
if item.type == "clothing"
fput "get ##{item.id}"
fput "drop ##{item.id}"
end
}
Slark
11-05-2022, 12:11 AM
Add Dreaven's bit about looking in the container, and yours will work if you do clothing = container.contents.find_all instead of just find.
find will only return the first match, where find_all returns, well, all of them. You also don't need "my" when you reference something by its id.
onurb
11-05-2022, 01:36 AM
ty for the wisdom to both of you
onurb
11-15-2022, 12:39 AM
Here is my code snippet..
if line =~ /You are stunned/
when this example happens, all is good, my if line catches it
[SMR result: 207 (Open d100: 158)]
As a canny giant rat focuses on you, an overwhelming pressure assails your mind, rendering you thoughtless!
You are stunned!
when this example happens, my if line does not catch it. it seems like anything with a roundtime causes my if line not to catch it
A long thorny vine suddenly sprouts from the ground and begins to thrash about violently!
[SMR result: 103 (Open d100: 90, Bonus: 8)]
The long thorny vine lashes out violently at you, dragging you to the ground!
... 15 points of damage!
Leg sweep keeps your feet overhead.
You are stunned for 3 rounds!
Roundtime: 3 sec.
why is this?
onurb
12-18-2022, 10:52 PM
Trying to figure out how to detect an area web in the room and then dispel it before moving on. Here is what I got so far. I know the checkroom sticky web part isnt right, thats the part I am trying to figure out.
[Some Area, Some Room - 12345]
You notice a giant sticky web.
Obvious paths: north, east
direction = ["go portal", "ne", "ne", "ne", "n", "n", "n", "n", "e", "e", "n", "nw", "go steps", "n", "go spear", "w", "w", "w", "w", "n", "n", "climb steps", "go arch", "d", "climb steps"]
loop{
move direction[number]
if checkroom == "a sticky web"
if Spell[209].known?
Spell[209].cast('web') if Spell[209].affordable?
elsif Spell[417].known?
Spell[417].cast('web') if Spell[417].affordable?
elsif Spell[119].known?
Spell[119].cast('web') if Spell[119].affordable?
end
end
number += 1
number = 0 if number >= direction.count
}
Slark
12-22-2022, 11:25 AM
When you use a double equals, you're looking for an exact match. You probably want a regex match. Try something like if checkroom =~ /a sticky web/.
In situations like these, you may want to echo checkroom to see what you're working with.
Lavastene
12-22-2022, 12:11 PM
Also of note... the web is identified as "a giant sticky web" and you are only looking for "a sticky web".
onurb
12-22-2022, 12:46 PM
I dont think checkroom is the proper command though, it says in wiki checkroom checks the room titles. I am looking for a command that checks the room description which I think the "a giant sticky web" falls under.
Rinualdo
12-22-2022, 01:05 PM
;repo download webdispel
onurb
12-22-2022, 10:33 PM
;repo download webdispel
thanks, I did know there was some web dispel scripts out there. just trying to get in the habbit of writing my own to keep learning. but I did find the bit of code I needed on that script that I couldnt figure out
GameObj.loot.find { |item| item.name =~ /sticky web|cloud/ }
didnt even think about gameobj commands
thanks again!
onurb
12-29-2022, 07:44 PM
trying to understand something here. can you use regexes with split strings, like...
John kicks Steve in the neck.
Mike punches Todd in the leg.
if string =~ /(.*) (.*) (.*) in the (.*).|(.*) (.*) (.*) in the (.*)./
attacker1 =$1
action1 = $2
defender1 = $3
location1 = $4
attacker2 = $5
action2 = $6
defender2 = $7
location2 = $8
Does it work like this? or only works with 1 string?
Tgo01
12-29-2022, 10:12 PM
trying to understand something here. can you use regexes with split strings, like...
John kicks Steve in the neck.
Mike punches Todd in the leg.
if string =~ /(.*) (.*) (.*) in the (.*).|(.*) (.*) (.*) in the (.*)./
attacker1 =$1
action1 = $2
defender1 = $3
location1 = $4
attacker2 = $5
action2 = $6
defender2 = $7
location2 = $8
Does it work like this? or only works with 1 string?
Easiest way to test for this is to plug in all of the information at the following site: https://rubular.com/
Looks like $1, $2, $3, and $4 would be used for both sentences.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.