Author Topic: Using two different type of tools.  (Read 1920 times)

0 Members and 1 Guest are viewing this topic.

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Using two different type of tools.
« on: February 21, 2012, 08:18:33 PM »
0
I have run into a little snag,  I'm able to craft an item using
Code: [Select]
finditem CGG C   ;  hammer
if #findkind = -1 2
display ok put more Hammer in your backpack and hit play
halt
set #lobjectid #findid
event macro 17 0

I have try to add a sub to make more hammer when I run out. If I use the same line of though can't seen to ignore the tinker menu.

I have play with those set up
Code: [Select]
finditem CGG C   ;  Hammer
if #findkind = -1 2
gosub makehammer
set %hammer #findid
set #LOBJECTID %hammer
event macro 17 0

This is a script that I use to craft multiple items. it will run better if I didn't have to make crafting tool all the time.
thx for help

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Using two different type of tools.
« Reply #1 on: February 22, 2012, 01:07:42 AM »
0
That right there is why you don't want to use "old style" EUO code. I'm unsure about your design of the second bit, but once you understand what's going on with the "if" statement, you'll understand

Code: [Select]

if #findkind = -1 2

This means if the statement fails, the code will skip 2 lines.  This is a horrible way to control flow.  If you modify that code to look like this:

Code: [Select]
finditem CGG C   ;  hammer
if #findkind = -1
{
  display ok put more Hammer in your backpack and hit play
  halt
}
set #lobjectid #findid
event macro 17 0

Now you can add additional code to it without having to worry about formatting and counting how many lines to skip. 

This is left over from the early days or EUO and this type of "if" statement should be avoided like the plague.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Using two different type of tools.
« Reply #2 on: February 22, 2012, 06:24:56 PM »
0
I clean up the script, since to work, making news hammer and returning to crafting.   Thx for pointing out some misstake

Code: [Select]
x = + 281
y = + 456     ; was 413
set %itemtype KDP
set %weighunload 400

initevents
display ok Target your WOOD  in Packy
set #targcurs 1
wait 3
banktarget:
if #targcurs = 1
goto banktarget
finditem #ltargetid
set %bankbox #FINDBAGID
set %turnbag SZHEVQD

top:
for %1 %journalindex #jindex
{
   scanjournal %i
       if That_container_cannot_hold_more_weight. in #Journal
       {
        gosub Turn
        }
}
finditem TLK C_ , %turnbag   ;  wood  in pack

if #findstack < 6   ; if less then 5 pulp it pack , it will get more
{
   gosub Getboard
}

if #weight > 450
{
   goto makes:
}

if #weight > 375
{
   gosub Turn
}


if #contsize = 530_497
{
   set %makelastx #CONTPOSX + 281
   set %makelasty #CONTPOSY + 456      ; was 413
   click %makelastx %makelasty
}

if #contsize <> 530_497      ; was 437
wait 15
if #contsize <> 530_497       ; was 437
wait 15
if #contsize <> 530_497        ; was 437
{

finditem CGG C   ;  Hammer

if #findkind = -1
{
   gosub makehammer
}

set #LOBJECTID #findid
event macro 17 0
}
goto top

sub Getboard
set %packy %bankbox
finditem TLK C_ , %packy
exevent drag #findid  150
exevent dropc %turnbag
wait 30
return

makes:
wait 15
if #contsize = 530_497        ; was 437
click 1047 152 r               ; need to change this to   click
wait 15
goto top

sub turn
wait 10
key f10
wait 10
return

sub makehammer
finditem JTL C
set #LOBJECTID #findid
event macro 17 0      ;last object
wait 10 s
click  288 482   ; make last
wait 10 s
click  288 482   ; make last
wait 10 s
return
« Last Edit: February 22, 2012, 07:03:38 PM by The Ghost »

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Using two different type of tools.
« Reply #3 on: February 29, 2012, 07:20:55 PM »
0
your stuff is really, really hard to read! Try ovoiding gotos and try to do something like this (the stuff bellow is just an example, i wrote it fast so i dont know if it will work, but it should give you a hint how things should look like).

Code: [Select]
set %itemtype KDP
set %hammertype CGG
set %WeigtTurnIn 400
set %wood TLK

; Seting up wood bag and opening it
Display Target your wood bag(right?).
set #targcurs = 1
while #targcurs = 1
  wait 1
set %packy #ltargetid
set #lobjectid %packy
event macro 17
wait 1s

; Seting up turn bag and opening it
Display Target your wood pack(right?).
set #targcurs = 1
while #targcurs = 1
  wait 1
set %turnbag #ltargetid
set #lobjectid %turnbag
event macro 17
wait 1s

; Mainloop
repeat
  Gosub CheckForTurnIn
  Gosub CheckHammers
  Gosub CheckWood
  Gosub MakeItem
until #charghost = yes
; End of Mainloop

; Subs
Sub CheckForTurnIn
  if #weight > %WeigtTurnIn
  {
    finditem %itemtype C_ , #Backpackid
    while #findcnt > 0
    {
      key f10 ; YOU COULD DO BETTER THAN THIS AND YOU KNOW IT, but for now it's ok.
      wait 15
      finditem %itemtype C_ , #Backpackid
    }
  }
return

Sub CheckHammers
  finditem %hammertype C_ , #backpackid
  if #findcnt < 1
  {
    finditem %hammertype C_ , %packy
    if #findcnt > 0
    {
      exevent drag #findid
      exevent dropc #backpackid
      wait 20
    }
    else
    {
      display You are out of hammers.
      stop
    }
  }
return

Sub CheckWood
  finditem %wood C_ , #backpackid
  if #findstack < 10 ; if less than 10 in a stack then
  {
    finditem %wood C_ , %packy
    if #findcnt > 0 && #findstack > 10 ; if any wood in packy found and the stack os greater than 10
    {
      exevent drag #findid 150
      exevent dropc #backpackid
      wait 20
    }
  }
return

Sub MakeItem
  if #contsize <> 666_666 ; if contsize not XXX_XXX then we use the crafting tool ; ++ edit to the contsize of the crafting menu to get this working
  {
    finditem %hammertype C_ , #backpackid
    if #findcnt > 0
    {
      set #lobjectid #findid
      event macro 17
      wait 1s
    }
  }
  set %makelastx #CONTPOSX + 281
  set %makelasty #CONTPOSY + 456
  for %i 1 10 ; repeat 10 times
  {
    if #contsize = 666_666  ; edit the contisze of crafting menu to get this working
    {
      click %makelastx %makelasty
      wait 10
    }
  }
return
What you witness -- is whatver..
uogamers hybrid.

Tags: