ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Crisis on April 07, 2015, 08:40:19 PM
-
I am having difficulty filling a spellbook from scrolls in my backpack. I am crafting a circle at a time and then want to drop them into the spellbook but it is getting hung up after making them.
Finditem %Mage_Book C_ , #backpackid
set %Mage_Book #ltargetID
for %N 1 %N_Spells ; 1 to the # of spells in the book
{
gosub DragToSpellbook #backpackid %Mage_Book %scroll . %N ; %Scroll . %N = %Scroll(whatever value N Has)
}
I have the %Mage_Book set at the beginning of the script
set %Mage_Book MPF
I know it is something simple that I am overlooking in the script id'ing the book and setting it as the target
sub DragToSpellbook
;set %1 %ScrollSecure
;set %2 %spellbook
;set %3 %scroll . %N
finditem %1 G_2
if #FINDKIND = -1
return N/A
finditem %3 C_ , %1
if #FINDKIND <> -1
{
exevent drag #FINDID 1
wait 10
exevent dropc %2
wait 10
}
return
Do I need to do something different with the backpack since I am treating it like a secure?
-
Not that I'm a pro but I'm sure you need to use ID of the book not type.
Try to set the book first.
Display Target Your Spell Book to fill
set #targcurs 1
While #Targcurs = 1
Wait 1
set %2 #Ltargetid
-
As ghost said above.... your error is what you set mage_book to0. I would recommend you don't use the same var for both type and id
error code
Finditem %Mage_Book C_ , #backpackid
set %Mage_Book #ltargetID
Surely you should be setting a different var with for magebookid and also using the foundid not the last target. ie
Finditem %Mage_Book C_ , #backpackid
set %Mage_Book_ID #findID ; changes
for %N 1 %N_Spells ; 1 to the # of spells in the book
{
gosub DragToSpellbook #backpackid %Mage_Book_ID %scroll . %N ; changed mage_book to mage_book_Id
}
-
Not that I'm a pro but I'm sure you need to use ID of the book not type.
Try to set the book first.
Display Target Your Spell Book to fill
set #targcurs 1
While #Targcurs = 1
Wait 1
set %2 #Ltargetid
I am working on having my spellbook filler craft a book, craft a circle of spells, drop them onto spellbook, craft another circle etc. Right now this is separate but I hope to integrate it into my filler script. That way it can fill from scrolls in secure or craft and fill. I want it to find it automatically instead of user targeting.
Eventually when I am better, I will play with OCR so it will fill from secure and then craft and fill missing scrolls and complete spellbook. That will probably be a long time from now though lol. I am still working on scripting my way out of a wet paper bag, lol.
-
As ghost said above.... your error is what you set mage_book to0. I would recommend you don't use the same var for both type and id
error code
Finditem %Mage_Book C_ , #backpackid
set %Mage_Book #ltargetID
Surely you should be setting a different var with for magebookid and also using the foundid not the last target. ie
Finditem %Mage_Book C_ , #backpackid
set %Mage_Book_ID #findID ; changes
for %N 1 %N_Spells ; 1 to the # of spells in the book
{
gosub DragToSpellbook #backpackid %Mage_Book_ID %scroll . %N ; changed mage_book to mage_book_Id
}
I will look at this and give it a try after making the changes to my spellbook filler. ;D
-
The other didn't work, after looking at the target spellbook snippet
Display Choose the spellbook that you want to fill...
set #targcurs 1
while #targcurs = 1
wait 5
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
wait 10
I decided to try and modify it to autotarget a spellbook in the pack instead of a user having to manually target it
Finditem %Mage_Book C_ , #backpackid
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
wait 10
I put it into this sub here,
sub craftandfill
;craftspells not included here because it is working just fine to craft the scrolls, now i need it to fill the book
findItem * C_ , #backpackid
set %ScrollSecure ;not sure if I need this since it sets it on the next line but leaving it in here for now
set %ScrollSecure #ltargetid
set #lobjectid %ScrollSecure
wait 10
Finditem %Mage_Book C_ , #backpackid
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
gosub SetSpells
for %N 1 %N_Spells ; 1 to the # of spells in the book
{
gosub newstatus lime black 10 Filling Scroll %n : %N_Spells
gosub DragToSpellbook %ScrollSecure %spellbook %scroll . %N ; %Scroll . %N = %Scroll(whatever value N Has)
}
Thanks to the menu status EN suggested, I added it here as well and I can see that it is trying to drop the spells in my bag onto the book, they just aren't going. Well I guess I should say I see the status going through the different scrolls but nothing is being dropped and I am not hearing anything being moved. I did not add the sub for setspells nor the crafting sub that crafts the scrolls before it tries to fill the spellbook on here but it is in the script.
-
Another interesting (and faster) method is to context click the scroll. This brings up a 1 entry context menu that lets you target the spellbook to drop the spell into. It's actually faster than clicking/dragging the spells.
-
Another interesting (and faster) method is to context click the scroll. This brings up a 1 entry context menu that lets you target the spellbook to drop the spell into. It's actually faster than clicking/dragging the spells.
I am not sure what you mean, on OSI anyways, when I single click on a scroll nothing happens. I am confused but I am always up for a new way that is better.
-
I am not sure what you mean, on OSI anyways, when I single click on a scroll nothing happens. I am confused but I am always up for a new way that is better.
Right click? I kinda remember now that might have only been a RunUO thing..
-
I think so, when I right click it, my backpack closes.
-
The other didn't work, after looking at the target spellbook snippet
Display Choose the spellbook that you want to fill...
set #targcurs 1
while #targcurs = 1
wait 5
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
wait 10
I decided to try and modify it to autotarget a spellbook in the pack instead of a user having to manually target it
Finditem %Mage_Book C_ , #backpackid
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
wait 10
I put it into this sub here,
sub craftandfill
;craftspells not included here because it is working just fine to craft the scrolls, now i need it to fill the book
findItem * C_ , #backpackid
set %ScrollSecure ;not sure if I need this since it sets it on the next line but leaving it in here for now
set %ScrollSecure #ltargetid
set #lobjectid %ScrollSecure
wait 10
Finditem %Mage_Book C_ , #backpackid
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
gosub SetSpells
for %N 1 %N_Spells ; 1 to the # of spells in the book
{
gosub newstatus lime black 10 Filling Scroll %n : %N_Spells
gosub DragToSpellbook %ScrollSecure %spellbook %scroll . %N ; %Scroll . %N = %Scroll(whatever value N Has)
}
Thanks to the menu status EN suggested, I added it here as well and I can see that it is trying to drop the spells in my bag onto the book, they just aren't going. Well I guess I should say I see the status going through the different scrolls but nothing is being dropped and I am not hearing anything being moved. I did not add the sub for setspells nor the crafting sub that crafts the scrolls before it tries to fill the spellbook on here but it is in the script.
This is driving me nuts, could it be because I haven't actually targeted the spellbook? I tried to target it using event macro 8 5 but that ended up opening the spellbook on my paperdoll :(
-
I posted a filler script at RebirthUO in this thread that might give you some ideas:
http://rebirthuo.com/Community/index.php?threads/need-help-with-script.1167/
-
Ok 2 errors in this code
Finditem %Mage_Book C_ , #backpackid
set %spellbook #ltargetID
Finditem %spellbook
set %booktype #findtype
wait 10
Firstly If you want to set %spellbook to a found book you must set it to #findid not #Ltargetid (LAST TARGET) Remember when scripting its the same as doing things manually. When you find something you are not TARGETing it therefor LASTTARGET is not set.
General overview of when you do a finditem it creates and array of items that match the search criteria. This array of item is 0... #findcnt (findcount) For every item found it sets a whole bunch of #find??? vars EUO WIKI OF FINDITEM (http://wiki.easyuo.com/index.php?title=FindItem) Scroll down to related commands to see list of vars set.
Right after you do a finditem the var #findindex is set to 1 if one or more items are found. If you want to look at the 5th spellbook found you set #findindex 5 ... 2nd set #findindex 2 etc. This way you can loop through all the found items eg for #findindex 1 #findcount
Now back to your code... you do a finditem then set the %spellbook to lasttarget (not anything that was found but what ever you happened to target prior to running the script or while running script)... then you find the lasttarget and set booktype to its type. As you can see you will be getting nonesense values .. lets fix it
Finditem %Mage_Book C_ , #backpackid
If #findcnt >0
{
set %spellbook #findid
set %booktype #findtype
wait 10
}
else
{
display ok error no spellbook found fix that and start again
halt
}
(A) set %spellbook to #findid (first item found)
(b) No need to find it again we just did that .. so set %booktype to #findtype without doing another search.
(c) added an if condition incase no spellbooks found
-
ok, that doesn't seem to be working either so it may be something else that I over looked as well. I was trying to hold off putting up what I had because it is in the very beginning stages and I was going to add it to my filler once I had the kinks worked out. Mwinc told me I could use his crafting subs so I put them to use in this. At this time, it is supposed to craft a magery spellbook, craft all of the first circle spells and then drop them into the spellbook that was just crafted.
I have the %Resource_Container hardcoded at the top for now so you will need to add yours there because the script won't ask for it.
If it is finding the spellbook fine, did I make an error trying to use the backpack to pull scrolls from to drop in the book?
-
Tell us how it is failing....
does it craft book
does it craft scrolls
Give us a clue so we don't have to run it to help debug...
..
..
..
LOL is it by chance not placing the scrolls in the book ??
IF so your error is the same code that you removed from your other script... in the dragtospellbook sub you still have it do nothing if the spell is not on the floor...
remove all this code "finditem %1 G_2 if #FINDKIND = -1 return N/A"
Just to confirm something .. you do understand that when you are in a sub and the code reaches a return line it exits the sub and returns to the line right after the gosub command. It does not continue reading any more code in the sub even if their are 100 more lines in the sub. eg
gosub test
display ok here i am i exited early nothing was displayed
gosub test somethingofother
display ok sub printed bunch of nonsesne cool
halt
sub test
if %0 = 0
return ; no vars passed
; all code below here is never executed if %0=0
set %p 6
set %p %p x 2
display wow more code im in a sub
display that is one cool sub
return
-
Yea - I use break for that when I don't want to return.
-
Okay, I did forget to say that it is not dropping them in and I forgot to save it with set %mage_book MPF at the top of the script so it finds the spellbook.
I do have a couple of questions, first about the dragspells sub
sub DragToSpellbook
;set %1 %ScrollSecure
;set %2 %spellbook
;set %3 %scroll . %N
finditem %1 G_2
if #FINDKIND = -1
return N/A
finditem %3 C_ , %1
if #FINDKIND <> -1
{
exevent drag #FINDID 1
wait 10
exevent dropc %2
wait 10
}
return
%1 is the ScrollSecure and %3 is the scrolls so I am confused that about you saying that it is looking for scrolls on the floor so set %1 ScrollSecure, I was under the impression that finditem %1 G_2
if #FINDKIND = -1
return N/A
is saying that if the secure is not on the floor and g_2 means within two tiles right? I am hoping that I am reading it right, it is saying to check for the secure within 2 tiles of me, then move scrolls to the spellbook and the %1 %2 %3 is the order in which you make the gosub statement
I hope I am not coming off rude by asking, I am just really trying to understand the code and what it means. I have no true coding experience other than learning EUO and playing around with RUO scripts a few years back.
Anyways, with that line out, it still does not drop the scrolls into the spellbook.
Did I make a mistake with a return? I do understand that they are needed and that it stops reading there but I don't know much more about them then that. I quickly put this together to test out the dropping scrolls onto the spellbook when it wasn't working. I know I should never be in a hurry with a cut and paste but it is murphy's law lol.
-
My mistake .. now i see you are searching for the secure each time you drag, didn't register that before was thinking it was the scroll. So i was barking up the wrong tree but still got the right spot for the error... !!!!
Even thow i see what your doing now I still dont get why you would do this .. are you expecting the secure container to disappear from one spell to the next. Presumably you opened the container at some point so you know it exists and is open + You never know how people will use your script the secure that hold my spells is inside another secure and not on the ground at all. In my experience best to make it generic, open the secure don't matter where its located.
So the error is now obvious.... think about it .. is your backpack on the ground or is your player carrying it... !!!! Your paper-doll itself is a container and that container contains as one of the items your character backpack !!! Therefor character backpack is not on the ground and thus fails your ground search.
:D
-
I redid everything and have it working but it is very glitchy. It works great until it starts to meditate then it makes extra scrolls of ones already made and does not make others. I have not had any success with the check for scribe tool or making them. GRRR, I am very frustrated right now.
Known issues:
Crafting scribe and tinker tools: after it crafts the scribe pen, it makes one scroll and then gets stuck on crafting tinker tools. I am at a loss as to why though I am sure to an experienced eye it is something easy.
Well I fixed the crafting tools and now it is not meditating at all
When it was working, Meditation sub: it is interfering with making scrolls, it makes some duplicates and does not make others.
When it was working, Meditation sub: timing is not right, sometimes when it is full mana and tries to start crafting, I get a journal message saying you must wait to perform another action. It seems like it is counting crafting like casting a spell, if the med cool down is not up, you cannot make a spell scroll.
Script Status: Not showing when it is crafting the different circles of spells