Hey all,
I just picked up some of them there fancy auto-closing containers at snow town and, in so doing, discovered that sloot doesn't really work very well with them. It'll open the containers well enough but it doesn't detect the open or close messages so there's "unknown result" errors and it can't get my skinning knife and such.
I am completely new to Ruby and to scripting with this game (aside from simple Wizard or StormFront scripts anyway) but not new to programming concepts and making small patches so I figured this would be a good place to start (find a need and fill it, eh?).
Editing the script to add the different open and close messaging so that it recognizes when a container has been opened or closed, having it also recognize if a container is already opened or closed when it goes to open or close it, and having it look for enable_close_sacks and open my pouch to get my skinning knife were simple enough.
Where I'm having trouble is when attempting to sell everything. It seems that at times when sloot grabs an item and stows it that sometimes it will then attempt to `get <item> from <container>` and sometimes it will just `get <item>` and I can't figure out the determining factor. If it just attempts `get <item>` then the script will fail because the container is closed and it's not trying to `get <item> from <container>` so I can't add anything at that point to have it open the container.
Here's an example of what I'm seeing. I added an echo for GameObj.containers whenever sloot goes to get an item so that I can see the item numbers that it is seeing and where those items are so the output is a bit noisy, but first I kill a critter that has a stone on it which sloot dutifully picks up, opens my pouch, stows the stone, and closes the pouch:
[sloot]>search #121243274
You search the bone golem.
It didn't carry any silver.
It had a green malachite stone on it!
It had nothing else of value.
A bone golem's remains wither into dust.
>
[sloot: {"121231567"=>[#<Games::Gemstone::GameObj:0x000000001bda16a8 @id="121231568", @noun="knife", @name="skinning knife", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001bdaba90 @id="121231571", @noun="pass", @name="Chronomage day pass", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001bda9ec0 @id="121231570", @noun="chocolate", @name="carafe of white hot chocolate", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001bda8318 @id="121231569", @noun="match", @name="match", @before_name="a", @after_name=nil>], "121231538"=>[], "121231544"=>[#<Games::Gemstone::GameObj:0x000000001be8baa0 @id="121231563", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be89ef8 @id="121231562", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be88350 @id="121231561", @noun="moss", @name="some basal moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be82770 @id="121231560", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be80bc8 @id="121231559", @noun="moss", @name="some ephlox moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be7afe8 @id="121231558", @noun="lichen", @name="some wolifrew lichen", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be79440 @id="121231557", @noun="stem", @name="some aloeas stem", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be73838 @id="121231556", @noun="moss", @name="some ephlox moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be71c68 @id="121231555", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be700c0 @id="121231554", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be6a4b8 @id="121231553", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be68910 @id="121231552", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be62d08 @id="121231551", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be61160 @id="121231550", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be5b580 @id="121231549", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be599d8 @id="121231548", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be53df8 @id="121231547", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be52250 @id="121231546", @noun="stem", @name="some aloeas stem", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be506a8 @id="121231545", @noun="leaf", @name="some ambrominas leaf", @before_name="", @after_name=nil>]}]
[sloot]>get #121243324
You pick up a green malachite stone.
>
[sloot]>put my stone in #121231567
You put a green malachite stone in your burlap belt pouch.
>
[sloot]>close #121231567
You slide the small lever on the side of the burlap belt pouch, causing the metal plates at the top to snap closed.
>
--- Lich: sloot has exited.
Alright, so far, so good. Now to run `sloot sell` and it runs me to the gemcutter where the echo command shows the stone in the pouch but sloot simply attempts `get <item>` which of course fails because the game can't find that item since the pouch is full:
[Gemcutter's, Front Room - 1776]
--- Lich: go2 has exited.
Inside the Gemcutter's shop, you see two glass showcases holding jewelry and precious stones. Directly ahead of you is a scorched low desk with several racks holding tools of the Gemcutter's trade. You also see the gem dealer and a blackened narrow door.
[sloot: {"121231567"=>[#<Games::Gemstone::GameObj:0x0000000015a05db0 @id="121243324", @noun="stone", @name="green malachite stone", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x0000000015a1f2b0 @id="121231568", @noun="knife", @name="skinning knife", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x0000000015a35fb0 @id="121231571", @noun="pass", @name="Chronomage day pass", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x0000000015a7a138 @id="121231570", @noun="chocolate", @name="carafe of white hot chocolate", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x0000000015a93d90 @id="121231569", @noun="match", @name="match", @before_name="a", @after_name=nil>], "121231538"=>[], "121231544"=>[#<Games::Gemstone::GameObj:0x000000001be8baa0 @id="121231563", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be89ef8 @id="121231562", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be88350 @id="121231561", @noun="moss", @name="some basal moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be82770 @id="121231560", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be80bc8 @id="121231559", @noun="moss", @name="some ephlox moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be7afe8 @id="121231558", @noun="lichen", @name="some wolifrew lichen", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be79440 @id="121231557", @noun="stem", @name="some aloeas stem", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be73838 @id="121231556", @noun="moss", @name="some ephlox moss", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be71c68 @id="121231555", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be700c0 @id="121231554", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be6a4b8 @id="121231553", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be68910 @id="121231552", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be62d08 @id="121231551", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be61160 @id="121231550", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be5b580 @id="121231549", @noun="potion", @name="rose-marrow potion", @before_name="a", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be599d8 @id="121231548", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be53df8 @id="121231547", @noun="leaf", @name="some acantha leaf", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be52250 @id="121231546", @noun="stem", @name="some aloeas stem", @before_name="", @after_name=nil>, #<Games::Gemstone::GameObj:0x000000001be506a8 @id="121231545", @noun="leaf", @name="some ambrominas leaf", @before_name="", @after_name=nil>], "121231564"=>[#<Games::Gemstone::GameObj:0x0000000018e2e8f8 @id="121243347", @noun="bone", @name="golem bone", @before_name="a", @after_name=nil>]}]
Also here: Tikoshi (Emp), Oary
[sloot]>get #121243324
Obvious exits: east, out
>
You feel at full magical power again.
You feel fully energetic again.
>
[uberbarv: **** 27 EXP Gained this Pulse ***** (05:00:40)+]
Get what?
The 'get item' portion of the code:
# Gets an item
get_item = proc { |item, sack|
waitrt?
next true if GameObj.right_hand.id == item or GameObj.left_hand.id == item or checkleft =~ /#{item}/ or checkright =~ /#{item}/
id = item.class == GameObj ? "##{item.id}" : item
echo GameObj.containers
if sack.nil?
fput "get #{id}"
elsif sack.class == GameObj or sack = GameObj[sack]
fput "get #{id} from ##{sack.id}"
else
fput "get #{id} from my #{sack}"
end
noun = item.class == GameObj ? item.noun : item
result = false
30.times {
waitrt?
if GameObj.right_hand.id == item or GameObj.left_hand.id == item or (checkleft and noun =~ /#{checkleft}/) or (checkright and noun =~ /#{checkright}/)
result = true
break
end
line = get?
if line =~ /is out of your reach/
sleep 4
next get_item.call(item, sack)
elsif line =~ /^You can't pick that up\.$|^Get what?$|crumbles and decays away.$|crumbles into a pile of dust!$/
break
end
sleep 0.10
}
result
}
What I can't figure out is what happens to cause this to run the `if sack.nil?` portion of the code? Why is the sack nil and what can be done to prevent that?
Thanks in advance for any push in the right direction someone can provide!