ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Guadah on September 14, 2011, 05:04:41 AM
-
; ###########################################
; ### CHECKING FOR BANKBOX ###
; ###########################################
sub check_for_bank
menu set status Checking for your Bankbox
event macro 3 0 bank
wait 10
gosub TM_AdvJournalScan bank VALID_ADVANCE Bank_container
if #result = #true
{
menu set status Looks like you're at the bank.
wait 10
return
}
gosub TM_TravelFromRunebook RE %bank_rune %bank_rune %bank_book
gosub reopen_bags
return
Problem: If you are not at the bank, it spams the whisper 'Bank' over and over. Stuck.
What it's suppose to do:
Whisper 'Bank' then if you see in the Journal that the bank opened ("Bank_container") Then it returns, opening bags preset in the menu.
If it does not open (by not seeing "Bank_container" in the journal, it is 'supposed' to move onto the Sub to Travel, then Reopen_bags... however it never gets there.
I've followed the script by manually moving it along. It whispers 'Bank' then moves into TM's Journal Handler, then returns to the whisper 'Bank'. NO IDEA why it's doing that.
-
One of my pet peeves is more than one exit from a sub.. i'm a true believer in every sub should contain only one return .. so try my edit and see what you get
if you get the message Looks like you're NOT NOT at the bank. when in fact you are .. then you have an issue with the usage of tms subs.
; ###########################################
; ### CHECKING FOR BANKBOX ###
; ###########################################
sub check_for_bank
menu set status Checking for your Bankbox
event macro 3 0 bank
wait 10
gosub TM_AdvJournalScan bank VALID_ADVANCE Bank_container
if #result = #true
{
menu set status Looks like you're at the bank.
wait 10
}
ELSE
{
menu set status Looks like you're NOT NOT at the bank.
gosub TM_TravelFromRunebook RE %bank_rune %bank_rune %bank_book
gosub reopen_bags
}
return
-
Seeing as you only have a single event macro 3 0 I'm assuming the issue isn't in the sub if it's repeating the "whisper bank" multiple times. BTW, did you initialize your journal somewhere in the script? That is part of TM's journal handling subs, you need to run the sync..
X
P.S. - I believe more than one return from a sub is sometimes the best option but I'm no EN ;)
-
Hmm... so EN you simply set a variable in your sub for what it will return once it gets to the end?
Is this simply coders preference? It seems like it would by much faster to simply make the sub exit as soon as possible instead of performing more checks before getting to the final return.
-
Hmm... so EN you simply set a variable in your sub for what it will return once it gets to the end?
Is this simply coders preference? It seems like it would by much faster to simply make the sub exit as soon as possible instead of performing more checks before getting to the final return.
It is no faster in any meaningfull manner to exit the sub early. You could compensate for anyslowness incurred buy doubling the LPC.
As to simply coders preference yes and no. Its good coding practice, it means you have clear code that is easy to bebug especially by others. If you have 2 4 6 8 10 or more exits from a single sub you can see how the complexitys of debuggin get more difficult.
If you look at my chartoolbox script you will see that in long subs i use this
if !cancontine {block of code}
if !cancontine {block of code}
if !cancontine {block of code}
So all i have to do is set !cancontinue #false and it goes all the way to the end of the sub. A good code parser wont even read the code in the block it will just skip it.
Anyway this isnt real coding so .. what ever works for you all is fine .. just my personal preferences is all.
-
I Shall Have to incorporate this into my work from now on for good practice.
-
Wow, why so complicated? have an indicateable Item(an ID or Type) in your Bank what you could scan for. When u find the ID your bank is open.I do this with a Decoration Item i never use it.
-
I normally just do a check for the #contsize, I think a bank has a unique contsize, but I could be very very wrong on this.
-
I'm opening the bank to get to Resource Bag(s). If it doesn't find that the bank opened in the journal, it'll recall to the bank rune in my Runebook. I'm then going to put in a safety check that once you recall to your bank rune, if you say bank and it doesn't open, it will halt the script and tell you to fix your rune location.
@EN I like your changes, going to use those. It didn't resolve the issue, but It's because I didn't initialize my journal.
@Crome. You were right, I never initialized the journal.
-
I normally just do a check for the #contsize, I think a bank has a unique contsize, but I could be very very wrong on this.
When i remind right, Bank have same propertys than a Metal Chest. I could be wrong as well but with an indicator in your bank you have a 7 line Code for open Bank.
finditem %Indicator C
while #findkind = -1
{
Event macro 1 0 Bank
wait 10
finditem %Indicator C
}
-
@Crome, I may have to adjust it to do that, but I like the way it's coded currently.
I don't get it, I deleted TM's ADVJOURNALSCAN Subs and replaced them in from a fresh download, just in case something was deleted, and it is still doing it.
bank
bank
bank
Blah
-
-
@Crome. You were right, I never initialized the journal.
You mean, @12x ;)
BTW, I'm looking at your posted code and I still don't see you initializing the journal before calling TM's journal scan sub. You need to do this if you want your call to the TM_AdvJournalScan sub to actually work. You're telling the sub to scan a journal "index" called bank but you never created it beforehand.
I see that you are first calling your "check_for_bankbox" sub, then when the journal scan fails you're traveling then heading to the "reopen_bags" sub which immediately sends you back to your "check_for_bankbox" sub which is still going to fail every time on the journal scan.
Fix your journal synch and you will fix that piece of the code flow.
X
-
saw an intresting post the other day about bank boxes and that the bank box when opened can be found on your paperdoll
finditem <metalchesttype> CA_ , #charid
-
Very Cool EN THAT I can most defiantly use!
I wonder... is it possible to read what is written on the crafting menu's? Say I go to make a spellbook, but click the wrong category, so I go to make the wrong item and it says "You do not have enough mandrake root to make that item." It does not hit the Journal, but if I can scan the menu, I can prevent that from happening.
-
You are better off just scanning for how many of the item you have, then keep trying to do the full craft clicks until that number increases, then you can break into the make last routines.
-
So, Gudah, did you fix your use of TM's journal subs yet? Did it help?
X
-
I wonder... is it possible to read what is written on the crafting menu's? Say I go to make a spellbook, but click the wrong category, so I go to make the wrong item and it says "You do not have enough mandrake root to make that item." It does not hit the Journal, but if I can scan the menu, I can prevent that from happening.
Sure you could with ocr... but it would be quiet significant work and processing load.