PDA

View Full Version : Looping question



nunye
10-31-2016, 08:37 PM
Nothing to see here.

drauz
10-31-2016, 09:00 PM
I'm still learning the ropes, so I decided to practice making my own "slightly" more complicated script. I maybe asking it to do something it completely can't do. It will purify the gems, it will put them away in their proper places, but it will not get out a NEW gem - it continues to sing to the old gem after it's been put away. Any ideas of how to do it within the current build of the script? I know there is likely a better way to do this, but for right now this is what I know, so this is what I'm going with. (Of course, if you want to post a better way to do it, too, I'm happy to deconstruct it and see if I can understand it!) Thanks! Also, can someone tell me how to put my script examples into one of those fancy boxes so they format good?

GameObj[Vars.lootsack].contents.each{|item|
if item.type =~ /ebongate|gem/
fput "get ##{item.id} from my #{Vars.lootsack}"
loop{
if Spell[1104].affordable?
multifput "prep 1004", "sing at ##{item.id}"
result = waitfor /filling the imperfections|as the very essence|gem becomes more perfect|shatter|crack|must be holding|what were you|appearing smoother and more pure|improves somewhat|cannot be/
waitcastrt?
if result =~/cannot be|as the very essence|filling the imperfections/
echo "Putting orb gem away"
fput "put ##{item.id} in my #{Vars.orbsack}"
elsif result =~/improves somewhat|crack/
echo "Putting gem away"
fput "put ##{item.id} in my #{Vars.gemsack}"
elsif result =~/shatter into thousands of fragments/
echo "OOPSIE!"
echo "Better see to that!"
pause_script
end
end
}
end
}

Check out the ;pure script and perhaps see what is different. About the only help I can give you.

m444w
10-31-2016, 09:40 PM
I really think you should checkout some of the basics of how ruby works via some online resources:

https://hackhands.com/beginners-guide-ruby/ is a great place to start to get some of the terminology down

and there are a few links at the bottom you can follow to learn even more.

Jymamon
10-31-2016, 11:08 PM
Never mind, wrong track now that I can check in game.

Donquix
10-31-2016, 11:31 PM
at the very least if you ask here start indenting and use the CODE markup tag. Arrgh, ma' eyes.

subzero
11-01-2016, 12:44 AM
I'm still learning the ropes, so I decided to practice making my own "slightly" more complicated script. I maybe asking it to do something it completely can't do. It will purify the gems, it will put them away in their proper places, but it will not get out a NEW gem - it continues to sing to the old gem after it's been put away. Any ideas of how to do it within the current build of the script? I know there is likely a better way to do this, but for right now this is what I know, so this is what I'm going with. (Of course, if you want to post a better way to do it, too, I'm happy to deconstruct it and see if I can understand it!) Thanks! Also, can someone tell me how to put my script examples into one of those fancy boxes so they format good?


You're getting stuck in your own loop; you never tell it to leave when it's finished with a gem. Try adding some breaks after you blow up or put away a gem. And for what it's worth, the script will pause indefinitely if you blow up a gem. I'm assuming that is intended, but you could automate having that all taken care of and then resuming the purification script. If that isn't in the plans, you may as well terminate instead.



GameObj[Vars.lootsack].contents.each{|item|
if item.type =~ /ebongate|gem/
fput "get ##{item.id} from my #{Vars.lootsack}"
loop{
if Spell[1104].affordable?
multifput "prep 1004", "sing at ##{item.id}"
result = waitfor /filling the imperfections|as the very essence|gem becomes more perfect|shatter|crack|must be holding|what were you|appearing smoother and more pure|improves somewhat|cannot be/
waitcastrt?
if result =~/cannot be|as the very essence|filling the imperfections/
echo "Putting orb gem away"
fput "put ##{item.id} in my #{Vars.orbsack}"
break
elsif result =~/improves somewhat|crack/
echo "Putting gem away"
fput "put ##{item.id} in my #{Vars.gemsack}"
break
elsif result =~/shatter into thousands of fragments/
echo "OOPSIE!"
echo "Better see to that!"
pause_script
break
end
end
}
end
}

nunye
11-01-2016, 01:00 AM
Thanks. Yeah, I was trying to get it working before I moved on to the gem shattered part. It's next.

nunye
11-01-2016, 01:12 AM
Works like a charm, thanks! I had tried break but too much EG made me put if in the wrong place.