ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Tutorials => Topic started by: chasemac140 on September 07, 2018, 08:16:43 PM

Title: Failing Hard
Post by: chasemac140 on September 07, 2018, 08:16:43 PM
So I read through these scripting tutorials.

I can't get my script to work. I even scrapped it and just copy and pasted his tutorial script for healing on F10. Got no where. Here was my initial script trying to make my guy just auto heal when lower than 90 HP.

;==============================================================
; Chase's Auto Healer
; version 1.0
; Shard OSI
; Purpose: AFK healing while being attacked by sheep
; Globals none
;==============================================================


;==========================Setup===============================
set %healpotHP ( #maxHits - 80 ) ; change this for how many points down to drink your heal pot
set %healbandagesHP ( #maxHits - 10 ) ; change this for how many points down to bandage yourself.
;=========================Main Loop============================

SUO:
repeat

onhotkey F10
   gosub UseBandage
if c in #charstatus
   gosub DrinkIt NUF

if #hits < %healbandagesHP && #sCnt > %timer_bandages_heal
   {
      gosub UseBandage
      set %timer_bandages_heal ( #sCnt + 60 )
   }

if #hits < %healpotHP && #sCnt > %timer_pot_heal
   {
      gosub DrinkIt UUF
      set %timer_pot_heal ( #sCnt + 10 )
   }
until #CharGhost = Yes
while #CharGhost = Yes
   wait 0
GoTo SUO







;===========================Subs=================================
sub UseBandage
   findItem ZJF C_ , #backpackID
      if #findkind = -1
         return
   set #lobjectID #findID
   set #ltargetKind 1
   event macro 17 0
   target 3
   event macro 23 0
   wait 5
Return

sub DrinkIt
   namespace push
   namespace local DIT ; short for DrinkIt
   finditem %1 C_ , #backpackID
      if #findkind = -1
         return
   set #lobjectID #findID
   set #ltargetKind 1
      event macro 17 0
      wait 5
   namespace clear
   namespace pop
Return


Can someone pick this apart and show me where I've been stupid or just not paid close enough attention?   

update. I know the sub is being called. Just to test I added

onhotkey F10
gosub HealME


then in the sub I added

display Hello there!

the message pops up on the screen just fine. Its like it cant use the event macros or doesnt recognize the itemtype.    
Title: Re: Failing Hard
Post by: Endless Night on September 08, 2018, 04:04:13 PM
do you have your backpack open.
Title: Re: Failing Hard
Post by: chasemac140 on September 09, 2018, 07:21:51 AM
yea, its open. I think. Hold on gonna go try again.

Yea no dice, it doesnt work.

;==============================================================
; Chase's Auto Healer
; version 1.0
; Shard OSI
; Purpose: AFK healing while being attacked by sheep
; Globals none
;==============================================================


;==========================Setup===============================
set %healpotHP ( #maxHits - 80 ) ; change this for how many points down to drink your heal pot
set %healbandagesHP ( #maxHits - 10 ) ; change this for how many points down to bandage yourself.
;=========================Main Loop============================

SUO:
repeat

onhotkey F10
   gosub UseBandage
if c in #charstatus
   gosub DrinkIt NUF

if #hits < %healbandagesHP && #sCnt > %timer_bandages_heal
   {
      gosub UseBandage
      set %timer_bandages_heal ( #sCnt + 60 )
   }

if #hits < %healpotHP && #sCnt > %timer_pot_heal
   {
      gosub DrinkIt UUF
      set %timer_pot_heal ( #sCnt + 10 )
   }
until #CharGhost = Yes
while #CharGhost = Yes
   wait 0
GoTo SUO







;===========================Subs=================================
sub UseBandage
   findItem ZJF C_ , #backpackID
      if #findkind = -1
         return
   set #lobjectID #findID
   set #ltargetKind 1
   event macro 17 0
   target 3
   event macro 23 0
   wait 5
Return

sub DrinkIt
   namespace push
   namespace local DIT ; short for DrinkIt
   finditem %1 C_ , #backpackID
      if #findkind = -1
         return
   set #lobjectID #findID
   set #ltargetKind 1
      event macro 17 0
      wait 5
   namespace clear
   namespace pop
Return
Title: Re: Failing Hard
Post by: Trigs on September 10, 2018, 10:55:29 AM
Nothing stands out at a quick glance

It's usually really helpful to step through the code to see what's not working. With the code stopped, you can hit F7 or F8 to step through the code line by line, one of them will "step in" to subs and follow the code, the other will just call the sub.

So while your char is damaged, and you have the EUO window up / focused you could hit F8 F8 F8 and walk through the code line by line, you should be able to logic mistakes or calls that are not working as intended.

I'll try to remember to test it out at home tonight
Title: Re: Failing Hard
Post by: chasemac140 on September 10, 2018, 08:02:56 PM
I appreciate it, Ill do this tomorrow.