View Full Version : Suggested New Procedures
markizano
11-29-2006, 03:06 AM
Hello. Im new to this Forum, but not new to SCAR. I was thinking for a while and I came up with two new Procedures to add to {.includes SRL\SRL\Core\Text.scar} I figured this would be the official site to post the new procedures to (I use sythe.org) as I hope that they will be added to the next version of SRL.
The first procedure is:
{************************************************* ******************************
Procedure KeyDownWait(Key: Byte; WaitTime: Integer);
By: Markizano
Description: Holds a key down for a certain wait period.
************************************************** *****************************}
Procedure KeyDownWait(Key: Byte; WaitTime: Integer);
Begin
KeyDown(Key);
Wait(WaitTime);
KeyUp(Key);
end;
The second Procedure is:
{************************************************* ******************************
Procedure KeyDownWaitEx(Key: Byte; WaitTime: Integer; Shift: Boolean; Ctrl: Boolean; Alt: Boolean);
By: Markizano
Description: Holds a key down for a certain period of time.
If Shift, Ctrl, or Alt is true, then it'll hold that key down while it presses
that key.
************************************************** *****************************}
Procedure KeyDownWaitEx(Key: Byte; WaitTime: Integer; Shift: Boolean; Ctrl: Boolean; Alt: Boolean);
Begin
If Shift = True Then
Begin
KeyDown(16);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(16);
KeyUp(Key);
end;
If Ctrl = True Then
Begin
KeyDown(17);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(17);
KeyUp(Key);
end;
If Alt = True Then
Begin
KeyDown(18);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(18);
KeyUp(Key);
end;
If (Shift = True) AND (Ctrl = True) Then
Begin
KeyDown(16);
KeyDown(17);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(16);
KeyUp(17);
KeyUp(Key);
end;
If (Ctrl = True) AND (Alt = True) Then
Begin
KeyDown(17);
KeyDown(18);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(17);
KeyUp(18);
KeyUp(Key);
end;
If (Shift = True) AND (Alt = True) Then
Begin
KeyDown(16);
KeyDown(18);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(16);
KeyUp(18);
KeyUp(Key);
end;
If (Shift = True) AND (Ctrl = True) AND (Alt = True) Then
Begin
KeyDown(16);
KeyDown(17);
KeyDown(18);
Wait(10);
KeyDown(Key);
Wait(WaitTime);
KeyUp(16);
KeyUp(17);
KeyUp(18);
KeyUp(Key);
end;
end;
Now instead of telling scar to press a key down, then telling it to wait then telling it to release the key, you can simply add one line of code instead of three. I also created an extended version of the code to hold down shift, ctrl and/or alt to determine whether or not these keys should be held down while pressing the key you would like to press. Again, I do hope these two procedures are in the next release of SRL. Have a nice day :D
Boreas
11-29-2006, 03:43 AM
What would this be used for besides angle and compass?
Well, they could be used for something other than RS, although I do not know what right now.
CamHart
11-29-2006, 04:10 AM
I might be wrong on this, but i generally wouldn't say that i hoped for my stuff to be in SRL untill i was like a developer or something. It shows, atleast in my opinion, an amount of over confidence... Now post the procedures and explain how useful it would be in SRL and then the chances of it getting put in would be much higher I believe.
Boreas
11-29-2006, 04:15 AM
Would save a few lines in this I guess.
{************************************************* ******************************
Function angledir(angle,Side:String): Boolean;
by: Boreas, based on makecompass by Wizzup? and highestangle by StarBlaster100
Description: Changes highest/lowest angle and the compass direction at the same time.
Parameters: angle is 'h' for highest and 'l' for lowest
Side is 'n' 'e' 's' 'w' for the directions like in makecompass
************************************************** *****************************}
Function angledir(angle,Side:String): Boolean;
Var
Fx, Fy, Dx, Dy : Integer;
ComMark: Integer;
Left_Right : Boolean;
Begin
MarkTime(ComMark);
Case LowerCase(Side) Of
'n' : Begin Fx := 566; Fy := 13; End;
'e' : Begin Fx := 560; Fy := 19; End;
's' : Begin Fx := 566; Fy := 27; End;
'w' : Begin Fx := 573; Fy := 20; End;
end;
If FindColor(Dx,Dy,723587,Fx,Fy,Fx,Fy) Then
begin
Result:=True;
case angle of
'h':
begin
if (Loggedin) then
begin
keydown(38);
sleep(1000 + random(100) + random(200));
keyup(38);
wait(1000 + random(100));
end;
end;
'l':
begin
if (Loggedin) then
begin
keydown(40);
sleep(1000 + random(100) + random(200));
keyup(40);
wait(1000 + random(100));
end;
end;
end;
Exit;
end
If Random(2) = 1 Then Left_Right := True
Else Left_Right := False;
If Left_Right Then
begin
case angle of
'h':keydown(38);
'l':keydown(40);
end;
KeyDown(VK_RIGHT)
end
Else
begin
case angle of
'h':keydown(38);
'l':keydown(40);
end;
KeyDown(VK_Left);
end;
Repeat
Wait((10)+ Random(10));
If(FindColor(Dx,Dy,723587,Fx,Fy,Fx,Fy))then
begin
Result := True;
break;
end;
Until(TimeFromMark(ComMark) > 7000);
If Left_Right Then
begin
case angle of
'h':keyup(38);
'l':keyup(40);
end;
KeyUp(VK_Right);
end
Else
begin
case angle of
'h':keyup(38);
'l':keyup(40);
end;
KeyUp(VK_Left);
end;
End;
Clash
11-29-2006, 04:34 AM
I might be wrong on this, but i generally wouldn't say that i hoped for my stuff to be in SRL untill i was like a developer or something. It shows, atleast in my opinion, an amount of over confidence... Now post the procedures and explain how useful it would be in SRL and then the chances of it getting put in would be much higher I believe.
I don't want to sound critical, I know that you're a member and I'm not and such, but I didn't think that being a developer was required to attempt to contribute to SRL? I may be wrong though, no offense intended.
markizano
11-30-2006, 05:24 AM
My orriginal intent was to extend on the 'TypeByte' procedure, these have been prcedures on my list to be known since i learned how to use the 'KeyDown' procedure. I just created two new procedures that i would like to contribute that involve saving. There have been several times when something has happened and i lost all of my work. Now what if i could add it to my script to save my work. Well, here are two procedures that will keep one from loosing his work.
Here's a procedure that will just send the keys to save work (this is based off of the two procedures from before):
{************************************************* *****************************
Procedure SaveProgress
By: Markizano
Description: Saves current progress. Given you already have saved your file.
************************************************** ***************************}
Procedure SaveProgress;
Begin
KeyDownWaitEx(83,50,False,True,False);
end;
This procedure will save the progress and if it finds the save dialog box, then it'll type a name, using 'TypeSend' by Mutant Squirrel:
{************************************************* *****************************
Procedure SaveProgressName(Name: String);
By: Markizano
Description: Saves current progress with a given name.
************************************************** ***************************}
Procedure SaveProgressName(Name: String);
Begin
KeyDownWaitEx(83,50,False,True,False);
Wait(1000);
TypeSend(Name);
end;
These two procedures have a more meaningful purpose in SRL (I believe). They can save your changes in the script right as you start it so that u can prevent changes to the code if you make a mistake (eg. forgetting to place the insertion point at a certain location if using SCAR for something other than RS). Or if you are working on a really big script and the power goes out, you haven't saved in a while, but you just ran the script recently. With this script in your main event, you don't have to worry about loosing large/crucial amounts of information. REMEMBER: These are only suggestions and not beggs to be placed in SRL. If there are only certain ppl who want to use these scripts, then they can use them.
lardmaster
11-30-2006, 07:11 PM
well i have written some nice procedures and asked for them to be added. some people were like "cool, this is great"... but nothing ever happened.
markizano
12-10-2006, 05:07 AM
I have two new procedures to suggest to be added to the next version of SRL. Here they are:
EDIT: Sorry Mutant Squrrel, I didn't mean to steal your procedure.
EDIT: *Deleted*
{************************************************* ******************************
Procedure MinimizeSCAR;
By: Markizano
Description: Minimizes SCAR to the utility tray at the bottom of the screen.
************************************************** *****************************}
Procedure MinimizeSCAR;
Begin
KeyDownWaitEx(77,50,False,True,False);
end;
This one will minimize scar for you if you know a script works and you just want to minimize it to the tray before the script actually begins it's procedures and whatnot. But make sure you start off with SCAR as your active window and you have "ActivateClient" somewhere AFTER the minimize procedure so that it'll swich to your client window after minimizing SCAR.
If any of these procedures are not added to the next version SRL, I hope that they are usefull to at least somebody.
Markizano
tarajunky
12-10-2006, 07:38 AM
well i have written some nice procedures and asked for them to be added. some people were like "cool, this is great"... but nothing ever happened.
Don't feel bad, we get the same thing as Devs. :)
There is a lot of focus on keeping SRL 'clean' so that it doesn't get bloated and unwieldly. That means that we don't add ANYTHING to the core files unless there is a general agreement among all the Devs that it belongs there.
There are always the xFunction includes like xMapWalk.scar and xObject.scar and all the rest. These include little extras that are not used regularly. Here again, you have to consider if a new function is useful and unique, or if it will rarely be used, or overlaps with an existing function.
I can't think of a single script where I included an xBlah file from SRL. Usually if there is something there that I would want to use, I just copy it directly into my script and run if there without loading up 20 other functions that I won't even use. I just seems wasteful to me. And since you didn't include it, there is no conflict from duplicate entries or anything like that. So, I kinda view the xFunction files as a code repository. In that sense, this section of the forums serves the same purpose, so it's good to add stuff here for other people to see.
markizano
12-22-2006, 11:25 PM
Guess what ppl, I have a brand new procedure that I would like to suggest to the developers of SRL:
Having problems with running away from your enemy in your script because your LinearWalk procedure doesn't work? Well what if you could set this new procedure into your script and tell it to Walk in a straight line until your foe is out of reach, here is the procedure:
For ppl who like using degrees when it comes to the unit circle:
(************************************************* ******************************
Procedure LinearWalkDegrees(Dist, Theta: Integer);
By: Markizano
Description: Walks in a straight line at a distance (Dist) from the centerpoint
of the player (you). Theta is based off of the unit circle and will determine
where your character will move. Generally:
0 = East
90 = North
180 = West
270 = South
360 = East (again)
and so on (measurements are in degrees).
************************************************** *****************************)
Procedure LinearWalkDegrees(Dist, Theta: Integer);
Var xR,yR: LongInt;
Begin
xR:=Round(648 + (Dist * Cos(Radians(Theta))));
yR:=Round(84 - (Dist * Sin(Radians(Theta))));
Mouse(xR,yR,2,2,True);
Flag;
end;
I think that this should replace the LinearWalk procedure that is already in SRL because it is more efficient at clicking on the screen and getting the character to move. If you want your character to move a multiple of times then type in the procedure or set it to repeat until a condition is met, just like you would when moving from one place to another using the Mouse procedure. These procedures, i suggest, should be put in place of LinearWalk in SRL\SRL\Core\MapWalk.scar
Yeah. Tara is right. And there are people who are sposed to add them in. (SRL Librarians). If it truley is amazing then yes it will be added. But just random things that probably no one will ever use then it probably wont be added.
markizano
12-31-2006, 06:57 AM
Yeah. Tara is right. And there are people who are sposed to add them in. (SRL Librarians). If it truley is amazing then yes it will be added. But just random things that probably no one will ever use then it probably wont be added.
Ok, i'll admit that MinimizeSCAR and SaveProgress may not be all that they're cracked out to be, but KeyDownWait(Ex) and LinearWalkDegrees I believe to be HIGHLY helpful and effective. I use them FREQUENTLY in my scripts. Honestly, I really do believe that they should be added to the next version of SRL. I may be saying this because I don't know SCAR enough to be without them or maybe something else, but these are IDEAS and I am simply suggesting them as I believe that they may be of use some day.
EDIT: This is just my opinion, think what you want to.
Boreas
12-31-2006, 07:09 AM
Don't worry about it. If people like them they can include in their scripts.
Hobbit
12-31-2006, 07:25 AM
yah I think you should stop pressing the devs to add it in...cause in other things im in the same position....it can get highly annoying and the more you push and get on their nerves the less likely-hood of them listening to you....jsut keep that in mind...
markizano
12-31-2006, 07:32 AM
^^ Ok, then could this thread just be my reference for ppl who use my scripts instead? Because I've made a few for some ppl and I linked them here to get the parts of the includes that they don't have.
NOTE: If this thread gets to be older than 14days and nobody has posted in it, then I shall stop posting in it, from that point on, it will be my reference for other ppl to use my scripts.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.