SRL Archive - General

Help with a smiple flash game script please?!


Tomnolan

2013-04-29 15:19:04

So basically I'm just learning to script in Simba. I'm currently creating a few small scripts for some simple, mouse only flash games.

However, I'm having trouble with one of my scripts.

The game (/begamer.com/flash-game/22600/monkey-dinner) consists of seating monkeys for food.. You click a monkey in the queue, then click on one of 3 empty seats (or an empty one out of the three).

So for this i created a procedure that uses colorfind to locate a monkey that is in the queue, and then a procedure that would seat them (also using colorfind, it would search for a brown color on the stool that IS vissible when a monkey ISNT sitting down). however, my script will select the monkey in the queue but will not seat it. the script does nothing after selecting a monkey in the queue.

program MonkeyGame;

procedure SelectingMonkey; // Uses colorfind to Locate a monkey in the queue.
var x, y: integer;
Begin;
if findcolor (x, y, 2913210, 281, 363, 303, 455) then // Finds monkey in queue
Begin
MoveMouse (x, y);
ClickMouse (x, y, 1); // moves mouse to bear and selects him.
end;
end;
Procedure SelectingTable;
var x, y: integer;
Begin;
if findcolor (x, y, 7066362, 729, 358, 738, 401) then // searches for the brown colour on the furthest away stool that
// is vissible when the monkey isnt sitting there (ie when the seat is vacant)
Begin;
MoveMouse (645, 223);
ClickMouse (645, 223, 1);//if the seat is vacant, the stool is selected.
end
else if not findcolor (x, y, 7066362, 729, 358, 738, 401) then //if not vaccant then...


if findcolor (x, y, 9232379, 595, 454, 603, 486) then
Begin; //same description as above but for each stool.
MoveMouse (x, y);
ClickMouse (x, y, 1);
End
else if not findcolor (x, y, 9232379, 595, 454, 603, 486) then

if findcolor (x, y, 5880557, 459, 565, 472, 593) then
Begin;
MoveMouse (x, y);
ClickMouse (x, y, 1);
End;
if not findcolor (x, y, 5880557, 459, 565, 472, 593)then
SelectingTable; // if no free seat is found, then the procedure is repeated.
End;



begin;

Repeat
SelectingMonkey;
wait (500); //This should look for a monkey in the queue untill a monkey shows up.
SelectingTable; //and then takes it to a table.
until (True)

repeat
SelectingMonkey; // This should carry out the two procedures but the Selectingtables
wait(500) // seems to do nothing.
SelectingTable;
until (false);
end.


Could some one have a look please? Would be greatly appreciated

Brandon

2013-04-30 11:32:23

You sire have an infinite loop and a loop that doesn't loop.


Repeat
Until(True); Does no repeating at all since the condition is always "False"


It's the same as:


do
{
} while(false);

It does it once but as soon as it checks the condition it breaks because while-loops only repeat when the condition is true.

Your second loop is infinite and you'll be pretty much stuck in that loop.

Not sure why no one helped you yet since this is Simba code.. should have easy for someone browsing these forums. Fix the standards a bit or wait until I get home to browse from a comp then I can help you.. Until then, I can only point out what seems wrong.

Tomnolan

2013-04-30 14:02:16

Thanks man! I've only been scripting in simba for 2 days so not sure about all of the syntax yet, I just thought it would make sense?

As I want the script to start when the game does, I thought the script would stop as the on keys aren't in the queue straight away and I have
SelectingMonkey;
SelectingTable;
Until (false)
well it will be false to start with because there is no monkey? (Hope that made sense)

Any help is appreciated and thanks for taking the time to reply.

rj

2013-05-01 17:28:34

From: Tomnolan
Thanks man! I've only been scripting in simba for 2 days so not sure about all of the syntax yet, I just thought it would make sense?

As I want the script to start when the game does, I thought the script would stop as the on keys aren't in the queue straight away and I have
SelectingMonkey;
SelectingTable;
Until (false)
well it will be false to start with because there is no monkey? (Hope that made sense)

Any help is appreciated and thanks for taking the time to reply.


IT would have to be


Repeat
SelectingMonkey;
SelectingTable;
Until (false)

Tomnolan

2013-05-01 17:39:52

Yer man,I just didn't type It all out, it is that in the OP