Jump to content
tribalart

Need some help with small script

Recommended Posts

Hi,

 

Im trying so set up a small script for a scrolling 2d game but i havn't used SCAR for years and i have never be good at it anyway.

Problem is to articulate the script (the Then ,If, Until)etc. Here what i have done so far

 

 

Here what i want to do (very simple)

 

 

 

 

program New;

 

Var

 

RedTitle, RedRocka, x, x1, x2, y, y1, y2, I : Integer;

 

Procedure Mining ;

 

BEGIN

 

RedTitle := DTMFromString('78DA63E461606060634001CFA034238CE6C35' +

'4F3015D8D2090604755F3195D8D30A639D7989951D40000201304' +

'05');

RedRocka := DTMFromString('78DA6354616060D0654001FF7372C0342394C' +

'FA88AA966AB83038A1A00922503B4');

 

 

 

Repeat // need to loop forever

i: = 1

If (FindDTM(RedTitle, x, y, 558, 620, 792, 780))then // to spot the message warning about special rock in chat(it s the only red message so easy)

KeyDown (68) //key "D" caracter runs to the left looking for rock

IF (FindDTM(RedRocka, x, y, 945, 545, 1055, 641) //the special rock(red) is under caracter feet

Then KeyUp(68) // Movement key is released, caracter stop

Then Wait(1000) //pause

Then MoveMouse (943, 333) //move mouse to the " Mine" button

then Wait(500) //pause

Then ClickMouse (943, 333, True) // CLick "Mine" button

Then Wait(180000) // Rock stay for 3 minutes so it mine there 3 minutes

Then KeyDown(65) ///running back to initial pos. border of screen (key A)

Then Wait( 10000) /// take ~ 10 seconds of running)

Then Keyup (65) ///Caracter Stop

Then MoveMouse (943, 333) /// and start mining regular rocks until new special rock ,clicking th e "Mine" button

then Wait(500) /// pause

Then ClickMouse (943, 333, True) /// click mine button

 

until ;

I := 25000 ///it s the loop

end.

 

 

 

Please How do i do to get this work? any help is welcome

Link to comment
Share on other sites

Needs to be something like this:

 

var
 RedTitle, RedRocka: Integer;

procedure Mining;
var
 x, y: Integer;
begin
 if FindDTM(RedTitle, x, y, 558, 620, 792, 780) then
 begin // to spot the message warning about special rock in chat(it s the only red message so easy)
   VKeyDown(68) //key "D" caracter runs to the left looking for rock
   case FindDTM(RedRocka, x, y, 945, 545, 1055, 641) of //the special rock(red) is under caracter feet
     True:           
     begin
       VKeyUp(68); // Movement key is released, caracter stop
       Wait(1000); //pause
       MoveMouse(943, 333); //move mouse to the " Mine" button
       Wait(500); //pause
       ClickMouse(943, 333, True); // CLick "Mine" button
       Wait(180000); // Rock stay for 3 minutes so it mine there 3 minutes
       VKeyDown(65); ///running back to initial pos. border of screen (key A)
       Wait(10000); /// take ~ 10 seconds of running)
       VKeyup(65); ///Caracter Stop
       MoveMouse(943, 333); /// and start mining regular rocks until new special rock ,clicking th e "Mine" button
       Wait(500); /// pause
       ClickMouse(943, 333, True); /// click mine button        
     end;
     False:
     begin
       VKeyUp(68); // Movement key is released, caracter stop   
       Wait(1000) //pause
     end;
   end;
 end; 
end;

begin
 RedTitle := DTMFromString('78DA63E461606060634001CFA034238CE6C35' +
     '4F3015D8D2090604755F3195D8D30A639D7989951D40000201304' +
     '05');
 RedRocka := DTMFromString('78DA6354616060D0654001FF7372C0342394C' +
     'FA88AA966AB83038A1A00922503B4');
 repeat // need to loop forever
   Mining;
 until False;
end.

 

It may not work the way you need, but that at least compiles the code.

But yeah, I am unsure if this is logically what you needed, though.

 

NOTE: You may have to recreate the DTMs, the datastrings had some weird spaces on em - so they might be invalid.

 

-Jani

  • Confused 1
Link to comment
Share on other sites

thanks a lot, i m going to try it now ^^

 

- - - Updated - - -

 

well the game is down, but that does look fine.

i ll be able to use it as model if i need, so tyvm

Really glad to hear it helps you out, and yeah.. I am pretty sure you need to do small edits here and there for the code, just to get the logic correct, but once you do - it will be running smoothly! It requires SCAR 3.37[+] then (I edited it with 3.38). :)

 

-Jani

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...