PDA

View Full Version : Script pausing issues



Saurven
08-30-2014, 07:38 PM
So I can't figure out how the "Active Hunting Scripts" line in Bigshot is of any use. I'm trying to run Smartmonk for the brawling, but from what I understand, I need to write a separate script to pause Bigshot, run Smartmonk, and continue on once critter is dead.
I set the attacking command in bigshot to wait 5, stance, wait 5
Then this script runs background


def hunt
matchwait "You are now in an offensive stance"
pause_script 'bigshot'
start_script 'smartmonk', [ 'punch']
wait_until { !running?('smartmonk') }
pause 2
unpause_script 'bigshot'
hunt
end

hunt

When Bigshot finds a critter, it stances, my hunt script pauses bigshot, and starts Smartmonk. Once the critter is dead, Smartmonk exits of it's own accord. Then I get a very long string of:
--- Lich: smartmonk has exited.
--- Lich: bigshot unpaused.
--- Lich: bigshot paused.
--- Lich: smartmonk active.
--- Lich: smartmonk has exited.
--- Lich: bigshot unpaused.
--- Lich: bigshot paused.
--- Lich: smartmonk active.
--- Lich: smartmonk has exited.
--- Lich: bigshot unpaused.
--- Lich: bigshot paused.
--- Lich: smartmonk active.
--- Lich: smartmonk has exited.
--- Lich: bigshot unpaused.

Am I missing something? I've tried wait_while { running?( 'smartmonk' ) } , and tried creating a seperate def for the unpause of bigshot after the wait_while for Smartmonk. I've also tried putting the whole thing in a loop instead of having it re-run the def_hunt. That was a failure as well.

Tgo01
08-30-2014, 07:54 PM
What did the loop code look like?



loop{
waitfor "You are now in an offensive stance"
pause_script 'bigshot'
start_script 'smartmonk', [ 'punch']
wait_until { !running?('smartmonk') }
pause 2
unpause_script 'bigshot'
}


I don't see why the above wouldn't work.

I don't see why your code wouldn't work either unless you have another script running with a definition also called hunt that is causing it to screw up. I think Tillmen said definitions defined in on script can be called by others.

Saurven
08-30-2014, 10:37 PM
Yeah, that's exactly what the loop looked like. I dunno. I'll rename my hunt script just in case that's causing something stupid to happen. "Hunt" is a pretty open terminology, considering I'm using two different scripts, specifically tailored for hunting.

Saurven
09-01-2014, 10:59 PM
As an update, I changed my script name and def name. Same issue. I also tried "if stance = offensive", and just had bigshot hide and stance. It would have to stance 3 or 4 times for my background script to notice that it was changed.
The only way I could get it to work properly was to have bigshot's attack string as "hide, roar at target" and put my other script to matchwait "You roar at". Now it works.

I'm assuming it's me, though.
Line = get doesn't seem to work in my scripts anymore. The same script I used to pick my boxes after a hunt, that was working great, is now bypassing all the "if line =~" and "elsif line =~" lines, and going straight to the bottom of the command list.
Unfortunately I had my last match for wedging. Normally I'd "detect my #{GameObj.Right_hand.noun} " and when it came back "You have discovered no trap", it'd echo "Safebox: going to pick line", and grab a pick.
Instead, it detected the box, didn't echo shit, grabbed a wedge, and started going to town on the box. Thank Christ there was no trap on that box.

If it weren't for problems, life would be so dull.

Tgo01
09-01-2014, 11:40 PM
I really don't know what's up with your original script so I dunno.

As far as the problem you're having with line = get we would need to see the code you're using.

Saurven
09-02-2014, 12:13 AM
Here's the whole thing:



$scales = false
$pickee = Array.new
$scaleknife = "knife"
$knifesack = "sheath"
$ptrick = "twist"
$unpicked = Array.new

# Global Constants
$trapsafe = ["^A thin layer of mud or putty has been dabbed on the connecting point of the striking arm and the white substance to prevent it from igniting the .+ when it is unlocked\\.$",
"^A thorough and careful search of the lock mechanism indicates that the entire .+ is MANGLED. It's probably not trapped anymore\\.$",
"^A thorough search of the area inside the tumblers reveals what appears to be a metal bracket of some sort, although it seems to be empty now\\.$",
"^Feeling around the inside of the lock, you notice that the casing is coated with a rough, grainy substance\\. A small section of the casing has been scraped clean of the strange substance\\. You lean forward and peer between the walls of the casing\\. Examining the lock closely, you notice a deflated bladder wedged between the tumblers\\. There is a small hole in the bladder, most likely from whatever ruptured it\\. The lock emanates a strong scent of sulphur\\.$",
"^Knowing how delicate magical glyphs can be, you scrape some extra lines into the markings hoping to alter their meaning and defeat the spell they may hold\\.$",
"^Looking closely at the lock, you spy a small metal housing set just inside the lock mechanism, but it appears empty\\.$",
"^Looking closely into the keyhole of the lock, you spy a small metal housing, which appears to be empty\\.$",
"^Looking closely into the keyhole of the lock, you spy a small vial of fire-red liquid and a tiny hammer device which has been bent from striking range of the vial\\.$",
"^Looking closely into the keyhole of the lock, you spy a small vial of liquid and a tiny hammer device which has been bent from striking range of the vial\\.$",
"^Looking closely into the keyhole of the lock, you spy a small, dark crystal which seems imbedded in the locking mechanism\\. It looks as if opening the lock without the exact key could shatter it, but parts of the mechanism have been ground away to avoid unwanted contact with the crystal\\.$",
"^Looking closely into the keyhole of the lock, you spy a tiny hammer device and several splinters of glass\\.$",
"^Looking closely into the keyhole of the lock, you spy a tiny hammer device which has been bent back slightly\\.$",
"^Looking closely into the keyhole, you notice a pair of small metal rods that have a slight reddish glow about them\\.$",
"^Looking closely into the keyhole, you notice a pair of small metal rods that have been bent in opposite directions of each other\\.$",
"^Peering closely into the lock, you spy a tiny vial placed just past the tumblers of the lock mechanism\\. A small ball of cotton has been pushed up against the vial, protecting it from anything that may shatter it\\.$",
"^Peering in through the crack between the lid and the casing, you see what appears to be a thin cord dangling from the case\\. It looks to have been sliced through\\.$",
"^Peering into the .+'s lock, you see a small tube towards the bottom of the tumbler mechanism\\. It appears as though the tube has been plugged with something\\.$",
"^Peering into the .+'s lock, you see a small tube towards the bottom of the tumbler mechanism\\. A crimson glow surrounds the mouth of the tube\\.$",
"^Peering into the .+'s lock, you see a small tube towards the bottom of the tumbler mechanism\\. It appears as though the tube used to be covered with a thin membrane, but it has torn mostly away, and greyish-green powder covers the area around it\\.$",
"^Reaching inside the hole with the tip of your lockpick, you nudge the end of the flag to one side, so it will collide with the inside of its housing, should it try to emerge\\.$",
"^Suddenly, a tiny flag pops out of a hole next to the lockplate with a metallic CLICK! The flag vibrates there for a moment, then unfurls slowly, revealing a bright red starburst pattern on a white background\\. Written in big black letters inside the starburst is the word \\\"BOOM!\\\"$",
"^Taking a lump of putty from your .+, you carefully apply it to the end of the small tube\\. That should block whatever it's meant to deploy\\.$",
"^The lock appears to be free of all obstructions\\.$",
"^Using a bit of putty from your .+, you cake a thin layer on the lock casing, hopefully sufficient to prevent sparks when the metal arm strikes it\\.$",
"^Using a bit of putty from your .+, you manage to block the tiny hole in the lock plate\\.$",
"^Using a pair of metal grips, you carefully remove a slender steel needle from the .+ and cover the tip with a bit of putty\\.$",
"^Using the metal grips from your .+, you manage to reach in and grasp the post of the metal hammer, and bend the weak metal out of striking range of the vial\\.$",
"^Using the pair of metal grips, you manage to pull out the two pins that hold the upper and lower jaw pieces together\\. As the pins are removed, the jaws suddenly close and warp under the tremendous strain applied by their arming mechanism\\.$",
"^Using the pair of metal grips, you manage to pull out the two pins that hold the upper and lower jaw pieces together\\.$",
"^Using your metal grips, you carefully remove a pair of small steel jaws from the .+ before piecing the apparatus back together\\.$",
"^With a little force applied to the springs, you manage to pop them inside the .+, from within which comes the tinkle of breaking glass, followed by a strong acrid smell\\.$",
"^With a little force applied to the springs, you manage to pop them inside the .+, where they bounce around for a moment\\. You also hear something else rolling around in there\\.$",
"^With a little ingenuity you manage to grind down parts of the lock mechanism with your metal file, so it won't come in contact with the crystal when you try to open it\\.$",
"^With great care you take a pair of metal grips and bend the sensitive metal rods out of alignment\\. It looks as though they cannot be pressed together by the lock mechanism any more\\.$",
"^With utmost care, you slip your .+ into the lock and gently nudge the tiny gem until it begins to work loose and its inner glow begins to fade\\. Another moment of prodding, and you are able to poke the gem free of its metal housing, whereupon it falls down into the lock mechanism and out of sight\\.$",
"^With utmost care, you slip your .+ into the lock and gently nudge the tiny gem until it begins to work loose and its inner glow begins to fade\\. Suddenly, it violently pops free of its metal housing and bounces around inside the tumblers for a moment before vanishing down into the .+!$",
"^With utmost care, you slip your .+ into the lock and gently nudge the tiny gem until it begins to work loose and its inner glow begins to fade\\. Tilting the .+ forward, you knock the gem free of its metal housing and poke it out through the back of the lock, allowing it to gently roll down the inside of the .+'s front wall\\.$",
"^You can see what appears to be a tiny hole next to the lock plate which doesn't seem to belong there\\. However, nothing about it seems to indicate cause for alarm\\.$",
"^You carefully pour the contents of a.+ onto the .+ where you think the keyhole ought to be\\. Amidst a cloud of acrid smoke, the metal plate covering the lock begins to melt away\\.$",
"^You carefully push a small ball of cotton into the lock mechanism, surrounding and protecting the small vial from anything that may shatter it\\.$",
"^You carefully use the tip of a small metal file to scrape away the rough, grainy substance which lines the walls of the casing\\. After a few moments, you feel comfortable with the small section you have cleaned\\. You take out a thin needle and carefully slide it between the walls of the casing, taking great care not to touch them. As the tip of the needle punctures the small bladder, a strange clear gel oozes forth from the hole\\. The gel gives off a strong odor of sulphur\\. As the air hits the gel, it begins to harden and turn to dust, blowing away in the wind as if it never existed\\.$",
"^You discover no traps\\.$",
"^You notice a discolored oval ring around the outside of the .+ which makes you suspicious\\. Your suspicions are confirmed when you look inside the keyhole and notice the spring-loaded jaws pressed flush against the .+ walls, but the pins that hold the jaws together have been pushed out\\.$",
"^You notice a discolored oval ring around the outside of the a.+, but further examination gives the impression that some vital part of whatever trap was here has been removed\\.$",
"^You notice some spiderweb-like scratches on the lock plate which seem, after some bit of scrutiny, too organized to be just wear and tear -- it might be some type of glyph spell, but some of the markings have been altered\\. This may prevent any magical nature they have from manifesting itself\\.$",
"^You see a metal plate covering the lock plate, but it appears to have been melted through, granting sufficient access to the lock to attempt picking it\\.$",
"^You see a tiny hole next to the lock plate which has been completely plugged\\.$",
"^You take a vial out of your .+ and carefully pour the contents onto the .+ where you think the keyhole ought to be\\. Amidst a cloud of acrid smoke, the metal plate covering the lock begins to melt away\\.$"]


def scaletrap2()
fput "get my #{$scaleknife}"
loop{
fput "disarm my #{GameObj.right_hand.noun}"
line = get
if line =~ /^You gently slide your knife into the space under the lid and slice through the cord/i
break
else
end
}
fput "put my #{$scaleknife} in my #{$knifesack}"
fput "Drop my #{GameObj.right_hand.noun}"
startup
end

def scaletrap()
waitrt?
$scales = true
pickbox
end

def pickbox()
fput "get my black lock"
loop{
fput "lm ptrick #{$ptrick} my #{GameObj.right_hand.noun}"
line = get

if line =~ /^Click/i
break
else
end
}
if $scales = true
fput "put my lock in my satchel"
scaletrap2
else
fput "drop right"
fput "put my lock in my satchel"
end
end

def platetrap()
waitrt?
fput "get my wedge"
fput "lm wedge my #{GameObj.right_hand.noun}"
loop {
line = get
if line =~ /^The lid of a/i
fput "stow my wedge"
fput "drop my #{GameObj.right_hand.noun}"
break
else
return
end
}
startup
end

def scarabtrap()
waitrt?
fput "disarm scarab"
fput "get scarab"
fput "stow my scarab"
pickbox
end

def picktrap()
loop {
fput "get my black lock"
fput "disarm my #{GameObj.right_hand.noun}"
line = get
if line =~ /#{$trapsafe.join('|')}/i
pickbox
break
else
return
end
}
end

def normtrap()
loop{
fput "disarm my #{GameObj.right_hand.noun}"
line = get
if line =~ /#{$trapsafe.join('|')}/i
break
elsif line =~ /^You carefully nudge the scarab free|The scarab falls from/
waitrt?
fput "disarm scarab"
fput "get scarab"
fput "stow scarab"
break
else
return
end
}
pickbox
end

def disarmbox()
$pickee.delete(GameObj.right_hand.id)
fput "detect my #{GameObj.right_hand.noun}"
loop {
line = get
if line =~ /^It looks like a|It looks like an/i
disarmbox
elsif line =~ /^You discover no traps/
pickbox
elsif line =~ /^Despite heavy scrutiny, .+ suggests that it is trapped./
scaletrap
elsif line =~ /^No matter how hard you try/i
picktrap
elsif line =~ /^You carefully nudge the scarab free/i
scarabtrap
elsif line =~ /^The scarab falls from/
scarabtrap
elsif line =~ /^You don't seem to have any way to get through that metal plate/
platetrap
elsif line =~ /^You still have a good enough picture/
disarmbox
else
echo "It's fucked up"
exit
end
}
end

def startup()
fput "Get ##{$pickee.last}"
if GameObj.right_hand.name == "Empty"
then exit
else
disarmbox
end
end

def findem()
GameObj.loot.find_all { |box| box.noun =~ /^box|strongbox|trunk|chest|coffer/i}.each { |picken|
$pickee.push(picken.id)}
startup
end

findem


Each time I try to it on a box, trap or no trap, it picks the box up, detects the box, and echo "It's fucked up" and exits.

Tillmen
09-02-2014, 01:06 AM
When you disarm a box, the first line is "You carefully begin to examine blah blah". So, in the disarmbox method, the first time the loop runs, line is "You carefully begin to examine blah blah", which doesn't match any of the if statements, so it goes to else and says it's fucked up.

A dothistimeout is better for that sort of thing. It will retry the command if there's a common message like "You may only havce 1 typeahead line.", otherwise it will wait until it sees one of the messages you supply or the time limit is up (10 seconds in this example). It skips over messages you don't care about, like the one causing trouble here, but also messages like people entering the room at just the wrong moment.


def disarmbox
$pickee.delete(GameObj.right_hand.id)
result = dothistimeout "detect my #{GameObj.right_hand.noun}", 10, /^It looks like a|It looks like an|^You discover no traps|^Despite heavy scrutiny, .+ suggests that it is trapped.|^No matter how hard you try|^You carefully nudge the scarab free|^The scarab falls from|^You don't seem to have any way to get through that metal plate|^You still have a good enough picture/
if result =~ /^You discover no traps/
pickbox
elsif result =~ /^Despite heavy scrutiny, .+ suggests that it is trapped./
scaletrap
elsif result =~ /^No matter how hard you try/
picktrap
elsif result =~ /^You carefully nudge the scarab free|^The scarab falls from/
scarabtrap
elsif result =~ /^You don't seem to have any way to get through that metal plate/
platetrap
elsif result =~ /^It looks like a|It looks like an|^You still have a good enough picture/
disarmbox
else
# timed out
end
end

Saurven
09-02-2014, 09:49 AM
That's what I had forgotten. I was right; it was me. Thanks, as always, Tillmen.