ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Coragin on May 28, 2009, 05:58:33 AM

Title: Can a scirpt have this basic type of setup....
Post by: Coragin on May 28, 2009, 05:58:33 AM
I didnt search, because I am SURE no one has ever asked this before, unless they wrote scripts for macroquest 2.

But can I set up my script to work like this....
(code snips taken from TM's how-to step one thread.
Code: [Select]

;Header
;==================================

set %var1 500
set %books 3
gosub setup
gosub main

Sub main
mainloop:
;all the crap the script does here
GoTo mainloop

Sub setup
;all setup commands here
return

This is very similar to MQ2, except most commands use the "/" switch, in MQ2 it would look like this...

Code: [Select]


|Header
|==================================

/set %var1 500
/set %books 3
/call setup
/call main

Sub main
:mainloop
|all the crap the script does here
/goto :mainloop

Sub setup
;all setup commands here
/return

As you can see, it is mostly the same, | used instead of ; and / use with goto and return and : used at the beginning of the command instead of the end.  But for the most part, it is exactly the same and if commands always started with the / switch.

But back to my main question, can the first code I wrote be used?  Having a Sub Main that is called right after setup that is the main loop?  I know for most of you, this is redundant, since just adding in loop: or mainloop: is basicly the same thing, but for me, it makes it easier to read.

I do not have access to UO ATM so I can make a simple script to test if it would work, thats why I am asking here, so I can learn.

Finally, am I the only one who thinks it would be much easier to have the command to use a skill like this

Code: [Select]
useskill hiding

Instead of...

Code: [Select]
macro (numbers here)
Title: Re: Can a scirpt have this basic type of setup....
Post by: Cerveza on May 28, 2009, 06:07:11 AM
Code: [Select]
gosub setup
gosub main

Sub main
mainloop:
;all the crap the script does here
GoTo mainloop

Sub setup
;all setup commands here
return

You don't need the lines

gosub main
sub main

Cause the script "falls" through to those lines anyways.

Take a look at the tutorials, there's one in there about basic script flow.

Header
Setup (if small)
-- gosub setup (if large)
MainLoop (*can* be a goto loop, better loops exist)
Subs
Menu
Title: Re: Can a scirpt have this basic type of setup....
Post by: Coragin on May 28, 2009, 06:15:15 AM
Cerveza,

Thats the thread I did read.  I know some lines are not needed, but as I said, its easier for me to read and kinda like what I am used to.  Since from what I can tell, it wont slow the script down, its just a few extra lines of code.  At least until I get the hang of things, then clean my scripts up. 

So, I do know that they are not needed, but my question is, will it work?  My guess is yes.