View Full Version : Detecting when the player moves.
Littma
12-02-2011, 05:55 PM
MOD PLEASE READ: Move to Scripting Help, thank you!
I'm attempting to make my first script and I'm having a difficult time getting all of my procedures that require moving to work correctly seeing it will preform the action and continue to search > click/right click the color before the player even gets to the object.
Hopefully there is a solution to this--I am assuming it's the way I've scripted some of my procedures so I will give out one as my example on picking something up.
procedure Example;
var
x, y : Integer;
begin
while (InvCount < 28) do
begin
if(FindColorSpiralTolerance(x, y, 12345, MSX1, MSY1, MSX2, MSY2, 41)) then
Mouse(x, y, 0, 0, False);
ChooseOption('Take');
end;
end;
It might be because I'm having a hard time understanding some of the advanced scripting methods available to me. I'd prefer not to use bitmaps when finding objects to pick up--instead pure color would flow a lot easier from my understanding.
My main objective in this procedure is to pick something up to fill the users inventory up with the item and then simply stop. I've tested multiple methods that I've come up with and nothing has seemed to work and this is what I've come down to. As I've said before, throughout my testing it does not detect when the player is moving (which I'd like it to sleep while the player is moving) though there's no way to accurately obtain how many ms it would take to get from object A to object B.
Seeing this is a RuneScape script and I'd hope to release it to the public one day (when it's fully done and ready) I'd just like to make sure it doesn't spam click and just wait while the character moves. I'm just not sure how--any assistance will be greatly appreciated :D
Why not use "Flag"?
(*.. code-block:: pascal
function Flag: Boolean;
Waits while flag exists.*)
procedure Test;
var oldCount, newCount : Integer;
begin
oldCount := InvCount;
// Mousing stuff to pick up the item
Flag;
newCount := InvCount;
if (oldCount < newCount) then
begin
// More stuff here
end;
end;
Littma
12-02-2011, 06:05 PM
Why not use "Flag"?
(*.. code-block:: pascal
function Flag: Boolean;
Waits while flag exists.*)
procedure Test;
var oldCount, newCount : Integer;
begin
oldCount := InvCount;
// Mousing stuff to pick up the item
Flag;
newCount := InvCount;
if (oldCount < newCount) then
begin
// More stuff here
end;
end;
That's a great idea! I actually forgot about flag, though I thought over a period of time that Flag would be out of date. Question, don't the variables 'oldCount, newCount' need to be identified? I'm pretty sure they do unless they are specific commands in Simba.
Edit: One last question, for the life of me I can't find anything that detects hover text! As in when it hovers over a color and it detects a certain series of words > then > preforms action. I know there's a command out there though I'm not too sure where to find the full command list.
Flag still works.
oldCount and newCount are "Identified" as local variables exclusive to the procedure/function in question.
procedure Test;
var oldCount, newCount : Integer;
begin
...
See there? They are local variables and are usable only by the procedure/function that "Identifies" them.
E: I just noticed your edit now, sorry.
You want "IsUpText" and the like.
if IsUpText('Take') then
begin
end;
That's a great idea! I actually forgot about flag, though I thought over a period of time that Flag would be out of date. Question, don't the variables 'oldCount, newCount' need to be identified? I'm pretty sure they do unless they are specific commands in Simba.
Littma
12-02-2011, 06:12 PM
Flag still works.
oldCount and newCount are "Identified" as local variables exclusive to the procedure/function in question.
procedure Test;
var oldCount, newCount : Integer;
begin
...
See there? They are local variables and are usable only by the procedure/function that "Identifies" them.
Thanks for clarifying that and I apologize if all of this sounds rather stupid--It's been awhile since I've attempted to script.
Continuing from my last question, "One last question, for the life of me I can't find anything that detects hover text! As in when it hovers over a color and it detects a certain series of words > then > preforms action. I know there's a command out there though I'm not too sure where to find the full command list." Which would be my last question I may possibly have for now =)
i luffs yeww
12-02-2011, 06:13 PM
if(IsUpText('whatever'))then do_whatever;
It does not sound stupid, don't worry. We are all glad to help, no matter the problem!
I answered that question in my edit once I saw your edit. I'm sorry for not seeing it sooner.
E: I just noticed your edit now, sorry.
You want "IsUpText" and the like.
if IsUpText('Take') then
begin
end;
Thanks for clarifying that and I apologize if all of this sounds rather stupid--It's been awhile since I've attempted to script.
Continuing from my last question, "One last question, for the life of me I can't find anything that detects hover text! As in when it hovers over a color and it detects a certain series of words > then > preforms action. I know there's a command out there though I'm not too sure where to find the full command list." Which would be my last question I may possibly have for now =)
Littma
12-02-2011, 06:17 PM
Thank you both for your answers! It's greatly appreciated and I'll be sure to give credit for assistance when I do release the script soon.
Edit: Hmm, putting it all together seems rather difficult (to me atleast)
procedure Example;
var x, y, oldCount, newCount : Integer;
begin
oldCount := InvCount;
if(FindColorSpiralTolerance(x, y, 12345, MSX1, MSY1, MSX2, MSY2, 41)) then
if IsUpText('Take') then
Mouse(x, y, 0, 0, True);
Flag;
newCount := InvCount;
end;
Is there any hover mouse command? Also is there a database on the commands? If there is I would most likely look there so I don't bother you guys so much with these most likely commonly asked questions.
I look forward to seeing your script. :o Good luck on it!
Thank you both for your answers! It's greatly appreciated and I'll be sure to give credit for assistance when I do release the script soon.
Kyle Undefined
12-02-2011, 10:49 PM
Thank you both for your answers! It's greatly appreciated and I'll be sure to give credit for assistance when I do release the script soon.
Edit: Hmm, putting it all together seems rather difficult (to me atleast)
procedure Example;
var x, y, oldCount, newCount : Integer;
begin
oldCount := InvCount;
if(FindColorSpiralTolerance(x, y, 12345, MSX1, MSY1, MSX2, MSY2, 41)) then
if IsUpText('Take') then
Mouse(x, y, 0, 0, True);
Flag;
newCount := InvCount;
end;
Is there any hover mouse command? Also is there a database on the commands? If there is I would most likely look there so I don't bother you guys so much with these most likely commonly asked questions.
MMouse(); moves the mouse to a point, so in a way it "hovers". Also, when you're in Simba, hitting "ctrl + space" will popup a list of all available functions/procedures. :)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.