Author Topic: Help :)  (Read 5869 times)

0 Members and 1 Guest are viewing this topic.

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Help :)
« on: June 11, 2009, 06:59:27 AM »
0
OK, OK...I am attempting to actually write/modify a script. What I want to make is a server line healer script. I know there is a lot of healing scripts out there but they all seem to require damaging your char, and I would like to try making one that utilizes a server line to do this.

So far, I have managed to write the first part..I can make my char walk 4 steps, turn around, and walk 4 steps back. WOOHOO!!!!!!

How would I go about writing in a pause after the 4 steps though, I am confused if I would actually need to make him pause, or just the act of using a bandage would make him pause (I dont think using the bandage will do it, I think I need a real pause)...right??

Here is what I have so far:

set %X #CHARPOSX
set %XX #CHARPOSX + 4
set %Y #CHARPOSY

menu text scriptstatus
HealTrainingLoop:
   {
   move %X %Y 0 4s

   move %XX %Y 0 4s
        }
Goto HealTrainingLoop
Return



hehe pretty simple for you guys, but it took me over a hour to do it LOL!!

Thanks
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help :)
« Reply #1 on: June 11, 2009, 09:37:08 AM »
0
After your second move, you could just apply the bandage and then add a "wait".  If you are bandaging yourself, the wait time is based off your healing/anatomy.  There's a formula on stratics that tells of this wait time, but is like 6 seconds or so.  So perhaps "wait 6s".  Dunno if that's what you had in mind.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: Help :)
« Reply #2 on: June 11, 2009, 09:39:44 AM »
0
Thanks TM, I actually managed to figure that out since I posted...now I am dealing with another problem (well, for me problem) LOL This is what I have

set %X #CHARPOSX
set %XX #CHARPOSX + 6
set %Y #CHARPOSY

menu text scriptstatus
HealTrainingLoop:
   {
   move %X %Y 0 6s
wait 200


I actually used a wait 200. I think that is 10 seconds...which would be what it takes to heal at only 20 skill...


   move %XX %Y 0 6s
        }

now, running this makes him move East and West

How do I change that to make him walk North and South??

Thanks!!!
« Last Edit: June 11, 2009, 09:42:31 AM by Toptwo »
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help :)
« Reply #3 on: June 11, 2009, 09:56:09 AM »
0
You just need to set another variable using #CHARPOSY + 6 just like you did for #CHARPOSX.  If you do it with a sub instead, it'll make it easier:

Code: [Select]
HealTrainingLoop:
  gosub MoveYourself 6 0
  wait 200
  gosub MoveYourself -6 0
  wait 200
  gosub MoveYourself 0 6
  wait 200
  gosub MoveYourself 0 -6
goto HealTrainingLoop
;---------------------------------
sub MoveYourself
  set %X #CHARPOSX + %1
  set %Y #CHARPOSY + %2
  move %X %Y 0 6s
return
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: Help :)
« Reply #4 on: June 11, 2009, 10:12:48 AM »
0
HOLY CRAP!!!!!!!!!!!!!

I (with your help, and cerv's tutorial) JUST WROTE MY FIRST SCRIPT!!!

and IT WORKS!!!!!!!!!!

I have it set up at a server line...wearing everything I can find to add HP (crimson etc...) When I cross server line and my HP goes down, the script throws a bandage on me...I heal...walk back across server line..and heal again..over and over...WOOOTTTTTTTTT!!!!!!!!!!
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Help :)
« Reply #5 on: June 11, 2009, 10:24:09 AM »
0
Now theres no stopping you!

Congrats!!
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: Help :)
« Reply #6 on: June 11, 2009, 10:26:55 AM »
0
Thanks Cerv!!

Here is what the whole thing looks like...dont know if it could be made more efficient or not...but I know it is working.

------------------------------------------------------------------------

gosub MoveYourself 0 6
  wait 160
  gosub MoveYourself 0 -6
goto HealTrainingLoop:

sub MoveYourself
  set %X #CHARPOSX + %1
  set %Y #CHARPOSY + %2
  move %X %Y 0 6s

FindItem ZLF C_ , #BackpackID
  if #findkind = -1
    {
      Display ok You have run out of bandages.$
            + Please get more and restart the script.$
            +$
            +Script is Halting$
            Halt
    }
Set #LObjectID #FindID

menu text scriptstatus 110 268 Using Bandage
Event Macro 17 0        ; Use Last Object (Bandages)
 Target
Event Macro 23 0        ; Target Self
wait 200
Goto HealTrainingLoop
Return
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help :)
« Reply #7 on: June 11, 2009, 10:33:17 AM »
0
Careful with what you are doing, you are jumping out of your subroutine.  That's bad mojo.  Follow the script flow a bit to make sure it's doing what you think it should be doing... 

Just get rid of the "goto HealTrainingLoop:" I don't think you have the tag, so it won't actually do anything, but it's good to understand that.

Also, you are relying on the script to start over again.  You might want to fix it so the loop happens under your control  perhaps something like this:

Code: [Select]
repeat
  gosub MoveYourself 0 6
  wait 160
  gosub MoveYourself 0 -6
until #FALSE

sub MoveYourself
  set %X #CHARPOSX + %1
  set %Y #CHARPOSY + %2
  move %X %Y 0 6s
 
  FindItem ZLF C_ , #BackpackID
  if #findkind = -1
  {
    Display ok You have run out of bandages.$
    + Please get more and restart the script.$
    +$
    +Script is Halting$
    Halt
  }
  Set #LObjectID #FindID
 
  menu text scriptstatus 110 268 Using Bandage
  Event Macro 17 0        ; Use Last Object (Bandages)
  Target
  Event Macro 23 0        ; Target Self
  wait 200
Return
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Help :)
« Reply #8 on: June 11, 2009, 10:35:56 AM »
0
Congrats M8!! :)

Just want to mention that it is good practice to avoid using GOTO statements to jump in and out of subroutines. In your example you may want to simply remove the "GOTO HealTrainingLoop" at the end of your MoveYourself sub.

If you wanted to, you could also break into an "ApplyBandage" sub and seperate that logic a litle bit from the move sub. Maybe something like:

Code: [Select]
Loop:
   Gosub moveyourself 0 6
   Gosub healyourself
   Gosub moveyourself 0 -6
   Gosub healyourself
GoTo Loop

Just some "good practice" stuff for ya but either way keep it up!!

XII

<edit> doh TM beat me to the Reply button!! :P
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: Help :)
« Reply #9 on: June 11, 2009, 10:44:13 AM »
0
Thanks Guys!

Yep, and with all you guys have said here I still managed a stinking goto :( live and learn!!!

TM..I think I understand...by putting return in there and the #FALSE, you are telling the script to run until stopped or until out of bandages...is that correct??


Thanks Guys!!

I might even get faster someday....that little timy bit o script took me 6 hours to accomplish LOLOL!!!
The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Help :)
« Reply #10 on: June 11, 2009, 10:52:37 AM »
0
You can most certainly use GoTo's - that's why the command exists; however, there is a time and a place. TM's example though is a good way to run your main loop without one, the "Repeat" tells the loop to run and the "Until" criteria is never met thus it loops indefinitely unless you have logic builtin elsewhere else to tell it to stop (like when you are out of bandages).

Most importantly, if you DO use a GoTo, NEVER (repeat - NEVER) use GoTo to hop between subs.

Also, I don't see a menu anywhere in there so I think you can get rid of your 'menu text' line.

XII
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help :)
« Reply #11 on: June 11, 2009, 10:53:23 AM »
0
Well the idea behind:

Code: [Select]
repeat
...
until #FALSE

This is really the same as:

Code: [Select]
loop:
...
goto loop

repeat/until #FALSE is an infinite loop since there's NOT a way for the until to be #TRUE.  ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Help :)
« Reply #12 on: June 11, 2009, 10:59:46 AM »
0
Didn't I say that?

:)
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Help :)
« Reply #13 on: June 11, 2009, 11:00:53 AM »
0
#TRUE is always true, unless it's false.

*TM made a mainloop without a goto  :o... sorry... got a little teary there....  :'(

It's the greatest day of my life!
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline ToptwoTopic starter

  • SunTigress's Hero!
  • Global Moderator
  • *
  • *
  • Posts: 2087
  • Activity:
    0%
  • Reputation Power: 21
  • Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...Toptwo might someday be someone...
  • Gender: Male
  • Respect: +131
  • Referrals: 1
    • View Profile
Re: Help :)
« Reply #14 on: June 11, 2009, 11:02:24 AM »
0
roflmao!!

The final weapon is the brain. All else is supplemental.....  If you find yourself in a fair fight, your tactics suck.

Tags: