ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: insand on December 05, 2011, 07:48:58 PM
-
Hello everyone,
I just recently got into writing my own scripts because what i need is not available anywhere, so far anyways.
I just have a few questions about my script. There are a few commands i was not able to find, or figure out.
I would like to know how i could "open" a runebook by "name" and then pick a chosen number then use sacred journey to that location. I have searched previous scripts that use this similar style but everything jumps back and forth so many times i have no idea what's going on anymore.
( Example:
if #weight > 400
open book X
sacred journey to X
open bank
dump ore, leather into bank )
My second question is how do i go about and completely empty my inventory, secure or chest of a chosen object (ore, wood, leather, cloth, etc...) into the bank or even into another chest for example?
Waiting anxiously to add codes to my script :D
-
Luckily these have been made available for us to use.
Trailmyx's Runebook/Spellcast Subs: http://www.scriptuo.com/index.php?topic=18.0 (http://www.scriptuo.com/index.php?topic=18.0)
EN's GENERIC MOVE ITEM/S TO CONTAINER http://www.scriptuo.com/index.php?topic=2454.15 (http://www.scriptuo.com/index.php?topic=2454.15)
-
here's more to play with
set %MAXstones 400
set %runebookid XXXXXX
sub checkweight
if #weight > #maxweight - 50 || #weight >= %MAXstones
gosub bankrun ; if using TM travel subs ( gosub TM_TravelFromRunebook SJ 2 2 %runebookid ) 2 2 starting with rune 2 and ending at rune 2
return
;------------------------
sub openbank
msg bank$
wait 20
if #contsize = 180_240 ;<<< bank box gump size
{
return
}
else
{
display ok Cannot locate bank, open bank and press play
pause
}
return
;-----------------------------
sub DUMPLOOT
set %dragspeed 10
set %dropbox XXXXXXX ; box in bank to drop loot set at beginning of script
set %droploot XXX_YYY_ZZZ_ ; ID's to dump
repeat
finditem %droploot C_ , #backpackid
exevent drag #findid #findstack
wait %dragspeed
exevent dropc %dropbox
wait 15
until #findkind = -1
return
-
repeat
finditem %droploot C_ , #backpackid
exevent drag #findid #findstack
wait %dragspeed
exevent dropc %dropbox
wait 15
until #findkind = -1
This is wrong. What happens if finditem = x(nothing found) ? -- it drags an non existing item ( well atleast send a packet to drag it and drop it )
I would use a while loop there or something similar...
Anyway, you would want to use something like this..
set %storage QWERTY
set %stuff LOOT_LOOT_ZLK_POF
Mainloop:
if #weight > ( #maxweight - 50 )
{
gosub Recall_from_named_book ORE 1 r 5 ; Recalling to home
gosub unload
gosub Recall_from_named_book ORE 2 r 5 ; Recalling back to cave
}
goto Mainloop
; gosub travel_named_book ore number r(for recal)/c(for sacred) retries
Sub Recall_from_named_book
finditem MPF C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
event property #FINDID
if %1 in #PROPERTY
{
gosub recall #findid %2 %3 %4
return
}
}
display your named book was not found.
stop
return
Sub Unload
finditem %stuff C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
exevent drag #findid #findstack
exevent dropc %storage
wait 30
}
return
Note that this is fastly writen for freddy's recalling sub, but as it seems he has withdrawn all his scripts, including the fastest recalling sub out there.. If you ask freddy he may still give it to you.
-
Excellent i will try these out and see what i can come up with. So far i checked out TM's recalling and there's way too much stuff in there. I was hoping for something plain and simple. My success chance will be 100% so i do not need failure retries.
Let you know how i do.
-
I am still trying to figure out how to use the recall sub from TM --> http://www.scriptuo.com/index.php?topic=18.0
I'm hoping I know how to use the actual recall sub, i chose the TM_TravelFromNamedRunebook
and i would write this as:
gosub TM_TravelFromNamedRunebook SJ 1 1 BOOKONE ( use book named BOOKONE, choose rune range from 1 to 1, using sacred journey )
I assume that for this particular gosub, it does not require the declaration of a sub in the "SUBS" section
The last part im not sure how to do, which is to add the following:
; gosub TM_AddUnderscore #CHARNAME
; set %charname #RESULT
Somewhere in the script. I'm also not sure how to edit this line, and or, if it even requires modification.
So far when i push the play button nothing happens, lol
I'm curious to know how to get this to work in a very, very small script. I need to see this work in the form of "push play, execute recall, finished" before attempting to include it into any other scripting.
-
I use it in this script.
http://www.scriptuo.com/index.php?topic=6523.0 (http://www.scriptuo.com/index.php?topic=6523.0)
-
Yea not so helpful, anybody else have any ideas?
I can't even find it in there.
I don't know much about this, so this is like giving a map to a blind person.
Is it even possible to put this recall sub into a 2-10 lines maximum? Seems you need over 200 lines to make this work...?
-
Yea not so helpful, anybody else have any ideas?
I can't even find it in there.
I don't know much about this, so this is like giving a map to a blind person.
Is it even possible to put this recall sub into a 2-10 lines maximum? Seems you need over 200 lines to make this work...?
Depending how good the security checks should be in your script.
Repeat until 2 lines
Get Property 1 Line
String manipulation 2-4 Lines
Gosub Call the Book 1 Line (and xxx lines behind depending on your scriptcode how you open book, checks, etc)
So without the real code behind, you can make it in 8 Lines:)
-
I assume that for this particular gosub, it does not require the declaration of a sub in the "SUBS" section
You Assumed WRONG ... All SUBS must be declared in the same file as you are using them in. You can access externally declared code by use of the call command. I believe that particular piece of TMs fine code is designed for inclusion not calling.
If you want a called piece of code you can use my subs... which i just uploaded. http://www.scriptuo.com/index.php?topic=9016.0 (http://www.scriptuo.com/index.php?topic=9016.0)
Or as chrome mentioned above you can create your own work... but just getting the runebook id from a name will take you more than 10 lines of code. (ps my code doesnot currently include that function).
-
There needs to be a sub, for every time you use gosub.
So all you need to do is add TM's subs in the bottom of the script. That lets you do " gosub TM_TravelFromNamedRunebook SJ 1 1 BOOKONE " whenever you need to in the script, using only the one line.
When you "gosub" in the top ( or whenever you use it) , it does those actions that are in the bottom.
you then add this:
; gosub TM_AddUnderscore #CHARNAME
; set %charname #RESULT
in the top of your script.
-
This is what I have:
gosub TM_AddUnderscore #CHARNAME
set %charname #RESULT
;***************************************************
repeat
if #mana > 10
wait 1
gosub TM_TravelFromNamedRunebook SJ 1 1 BOOKONE
until #CharGhost = YES
while #CharGhost = YES
wait 1
;************************************************
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
namespace push
namespace local TFNR
set !method %1 SJ
set !start_index %2 1
set !end_index %3 1
set !runbook_name %4 BOOKONE
if !method notin RE_GA_SJ
{
namespace pop
return #TRUE
}
if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
locatenamedrunebook:
finditem ZBN C_ , #BACKPACKID
if #FINDKIND <> -1
{
event property #FINDID
if !runbook_name in #PROPERTY
{
gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
}
else
{
ignoreitem #FINDID rbook
goto locatenamedrunebook
}
}
else
{
display ok Cannot locate specified runebook named , #SPC , !runbook_name
stop
}
ignoreitem reset rbook
namespace pop
return
For starters, i have no clue how to edit these lines, but even without edit it should still give me an error or something when i push play? I get nothing
-
do not edit his sub at all, you don't need to.
and add this to the bottom also:
;-------------------------------------------------------------------------------
; %1 - string to mung
sub TM_AddUnderscore
namespace push
namespace local AU
set !tempstring %1
AddUnderscore_loop1:
str pos !tempstring #SPC
if #STRRES <> 0
{
set !val #STRRES - 1
str left !tempstring !val
set !left #STRRES
set !val !val + 1
str del !tempstring 1 !val
set !tempstring !left , _ , #STRRES
goto AddUnderscore_loop1
}
set #RESULT !tempstring
namespace pop
return #RESULT
I forgot, the addUnderscore sub is not in his travel subs you downloaded.
-
Ah excellent i forgot about that
Well now i'm slowly making progress. I'm up to the point where it states that it cannot find runebook named n/a.
So now i just need to figure out how to change this.
-
paste his sub into your script again, this time don't edit ANYTHING! the only thing you will edit is in red...
gosub TM_TravelFromNamedRunebook SJ 1 1 BOOKONE
repeat
if #mana > 10
gosub TM_TravelFromNamedRunebook SJ 1 1 BOOKONE
until #CharGhost = YES
you don't need the "while" stuff in there.
This script as is, will just recall to that spot, then keep trying to recall to that spot, but it will be blocked cause you are standing at that runes location. unless you die, then it will stop
-
That solved the runebook named n/a problem. Glad to see that gone ;D
Now my issue as gotten further down the script, always good news.
It sticks around the the following area for several seconds then returns back to beginning, which repeats.
locatenamedrunebook:
finditem ZBN C_ , #BACKPACKID
if #FINDKIND <> -1
{
event property #FINDID
if !runbook_name in #PROPERTY
{
gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
}
else
{
ignoreitem #FINDID rbook
goto locatenamedrunebook
}
}
else
{
display ok Cannot locate specified runebook named , #SPC , !runbook_name
stop
}
ignoreitem reset rbook
namespace pop
return
My guess is that it's having difficulties with #FINDID variable?
p.s. How do you place code in a fancy gray box?
-
TMs Runebook subs are a single package you need all elements/subs to make it function correctly
You have not included all of tms work inside your script ... you need to add all the code in tms file to your script. Do not pick and choose which subs as all subs are required. The subs call each other. This is why it is not working
Its plainly obvious that its failing on gosub TM_TravelFromRunebook as that sub does not exist and so the line is ignored. Don't just add this sub add all subs.. as they gosub each other.
-
I was not aware of that. I did not know that the all the subs were related.
I used "everything" this time and it worked. Minor tweaks required then it's ready and i can move on to the other dozen things want to do ;D
Thanks a lot, we're getting somewhere now.
-
I was not aware of that. I did not know that the all the subs were related.
I used "everything" this time and it worked. Minor tweaks required then it's ready and i can move on to the other dozen things want to do ;D
Thanks a lot, we're getting somewhere now.
Cool, As you write more complex scripts people tend to take a generic function and make a sub out of it and then use "gosub" to that sub from many places and different functions... this is why TMs runebook work is not a single encapsulated Sub.
Once you get your head around the way things work you will be flying..
To insert code in the fancy code tags... [ code ] ... [ /code ] <--remove the spaces thiers a button for in on the toolbar insert code
-
Hello i have a question regarding: EN'S GENERIC MOVE ITEM/S TO CONTAINER snippet, found at http://www.scriptuo.com/index.php?topic=2454.15
I was wondering if it was possible to reverse this operation?
I now need this script to take an item from a secured container and place it in my backpack.
Also on a side note, the last step that i need for my script's completion is finding a script or snippet that macro's to create a blacksmith item. (Example: Tools, shovels, etc )
-
I actually figured out how to reverse this operation with just a few modifications to the script. Now my only issue is having this secured container open, but i believe i found something for that as well..
As for creating the items i wanted, i also found a way to do that :D
So far all is going well
It is now time to piece all my subs into one, and see how they work together
-
I actually figured out how to reverse this operation with just a few modifications to the script. Now my only issue is having this secured container open, but i believe i found something for that as well..
As for creating the items i wanted, i also found a way to do that :D
So far all is going well
It is now time to piece all my subs into one, and see how they work together
Cool sounds like you are making some serious progress.
-
Alright, I have one little question.
I haven't been able to figured this out yet.
I've decided to use the following snippet twice in my script: ( Provided by EN )
Sub ENs_MoveToContainor ; 3/31/08 - %1 Item %2 Containor %3 stack (Optional) %4 Wait (optional)
set !DragDropWait %4
if %0 < 4
set !DragDropWait 15
wait !DragDropWait
ExEvent drag %1 %3
ExEvent DropC %2
wait !DragDropWait
Return
Everything works fine, even during the reversed operation i ended up figuring out.
Here comes the problem area.
I use this snippet twice in my script to perform different tasks.
The issue is that the scripts cannot determine which set variables to use. Therefore i get items and quantities in areas they shouldn't be.
I tried adding the set variables within the sub, and that definitely didn't solve the problem.
The only other idea i have is to use the "Call" command and just have the second snippet saved in a separate file.
I'm not exactly sure on how to use the call command correctly within a script. I have read somewhere that "call" commands work similar to "gosub" commands.
Now i'm not sure how to set the variable.
How do i tell the "call" command to get the file from C:\windows\blahblah
-
Okay so turns out I should probably research a little more before posting, but these ideas come to me while i'm posting.
By placing all my script files inside my euox folder the program would auto detect the call locations.
I am still having the same issue, regardless how many times i split my subs up into call files.
Thought i should mention that i use the following code:
finditem %MyITemType C_ , #Backpackid
if #Findcnt > 0
set %ItemId #findid
In order to use the Item mover snippet the way i need.
Also, both my item mover snippets contain this code.
So it seems that which ever snippet i run first, the main script seems to be stuck with the #itemid of the first snippet ran.
Therefore, when calling the second snippet, it will automatically use the #itemid of the first.
And of course, both snippets work perfectly while on their own.
Any ideas?
-
Well I have managed to get around this problem. All I had to do was add numbers at the end of the variables, and the ones inside the finditem snippet.
So far i've gotten half of my script working at the moment because of this recent discovery.
Now my problem is with a snippet i've saved in (working condition) and now it is not...Fun, fun fun.
I don't have much to say about this yet, still in the works.
-
You only need to include my sub once within your code file and can then gosub it as many times as you need.