Jump to content

Master commands


Recommended Posts

Hey guys I have a command that I need to use at specific points in a script. I however don't want to type it out five hundred times. Is there anyway to write it once and then use a shorter command to run that large one? (I have much bigger ones.. but I figured for ease of explanation I'll use a shorter one)

Here is the command,

Sleep(1500)
        $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C )
    If Not @error Then
        Sleep($short)
    EndIf
    If @error Then
        Sleep(1000)
    EndIf

Is there a command that will direct my script to that command and have it run that? but the one I type into my script will be short like "DO $command1" and that script up there would be defined as $command1?

EXAMPLE: would be to have the long command at the start of the script and then through the script a goto command telling it to read those lines... However goto has been removed (its been a long time since I really scripted) so I don't know how to do it anymore. The reason for doing this is I'll be able to edit one master command and it will change them all throughout the script.

Edited by SwordHunter4Ever
Link to comment
Share on other sites

just declare it as a function

How would I go about doing this?

Sorry I'm not the greatest at this... (I'm going to go look in the helpfile, but if you could tell me what you know that would help as well).

Alright I found how to call a function, now I just need to know how to write one x_X

Or define something as one.

Edited by SwordHunter4Ever
Link to comment
Share on other sites

How would I go about doing this?

Sorry I'm not the greatest at this... (I'm going to go look in the helpfile, but if you could tell me what you know that would help as well).

at the end of your script, or alternatively in an include file, you would have:

Func _MyFunc($argument1,$argument2)

;place your code here

EndFunc

and then you would just call it in your script like:

_MyFunc($1,$2)

EDIT: of course the arguments can be any number, including none if you don't need them

Edited by maqleod
[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

at the end of your script, or alternatively in an include file, you would have:

Func _MyFunc($argument1,$argument2)

;place your code here

EndFunc

and then you would just call it in your script like:

_MyFunc($1,$2)

EDIT: of course the arguments can be any number, including none if you don't need them

So if I didn't have an argument it would look like

Func _Myfunc()

;code here

EndFunc

and then call it by

_MyFunc()

Link to comment
Share on other sites

and you NEED to have all of the parameters you set included so this would need to be

_MyFunc ($i, $j)
Func _MyFunc ($i, $j) 
EndFuncoÝ÷ Û*.çn±ëazƦzv¦z̨¹Æ§®¶­seô×gVæ2b33cµf#Âb33cµf#"¤gVæ2ô×gVæ2b33c¶Âb33c¶¢¤VæDgVæ

BUT YOU NEED To have all the parameters you specify

Link to comment
Share on other sites

and you NEED to have all of the parameters you set included so this would need to be

_MyFunc ($i, $j)
Func _MyFunc ($i, $j) 
EndFuncoÝ÷ Û*.çn±ëazƦzv¦z̨¹Æ§®¶­seô×gVæ2b33cµf#Âb33cµf#"¤gVæ2ô×gVæ2b33c¶Âb33c¶¢¤VæDgVæ

BUT YOU NEED To have all the parameters you specify

You lost me... here is my code,

;loadscreen waiter
Func _Loading()
    $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C )
        If Not @error Then
            Sleep(500)
        EndIf
        If @error Then
            Sleep(2000)
        EndIf
    EndFunc

and here is how I'm calling it,

Call("_Loading")

I'ms lightly confused by what you mean when you say "I need to have all the parameteres I sepcify", could you edit my code for me x_X or explain it a bit better?

Thanks a ton ^^

Link to comment
Share on other sites

well ill explain it.. to call a fun c with parameters.. you need to have the specified amount (im pretty sure)say.. your using this() you cant go

this()

func this($i,$j)

endfunc

you CAN do this

this()

Func This()

endfunc

AND

This($i,$j)

Func this ($i,$j)

endfunc

Link to comment
Share on other sites

You lost me... here is my code,

;loadscreen waiter
Func _Loading()
    $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C )
        If Not @error Then
            Sleep(500)
        EndIf
        If @error Then
            Sleep(2000)
        EndIf
    EndFunc

and here is how I'm calling it,

Call("_Loading")

I'ms lightly confused by what you mean when you say "I need to have all the parameteres I sepcify", could you edit my code for me x_X or explain it a bit better?

Thanks a ton ^^

You don't need to sue call() to call a user defined function. You could just do _Loading()
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...