SRL Archive - SRL Archives

A new ChooseOption :p


n3ss3s

2008-04-05 13:33:52


Function ChooseOptionEx(Text: String; Color: Integer; Action: ActionOptions): Boolean;

Var
dtm_Top, dtm_Bottom, tx, ty, bx, by: Integer;
TPA: TPointArray;
Txt: String;
BB: TBox;

Begin

dtm_Top := DTMFromString('78DA632C626460606662C006186134480D2B1' +
'16A7889502342404D1511EE6920424D2F613500F96003A5');

dtm_Bottom := DTMFromString('78DA63F46162600800622C80114683D47812A' +
'1C68E801A5722ECB224428D2E613500B821037B');

FindColorsTolerance(TPA, 0, MSX1, MSY1, MSX2, MSY2, 0);
BB := GetTPABounds(TPA);
Txt := GetTextAtEx(BB.x1 + 2, BB.y1 + 1, 9, UpChars, False, False,
0, 0, 4674653, 14, False, tr_Letters);
If LowerCase(Trim(Txt)) = 'choose option' Then
Begin
If FindDTM(dtm_Top, tx, ty, MSX1, MSY1, MSX2, MSY2) Then
If FindDTM(dtm_Bottom, bx, by, tx, ty, MSX2, MSY2) Then
Begin
FindColorsTolerance(TPA, 4674653, tx, ty, bx, by, 0);
BB := GetTPABounds(TPA);
Result := FindTextTPA(Color, 0, BB.x1, BB.y1, BB.x2, BB.y2, Text, UpChars, Action);
End;
End;
FreeDTM(dtm_Top);
FreeDTM(dtm_Bottom);

End;

Needs the ActionOptions type in Text.scar, tested, worked.

Richard

2008-04-05 14:15:06

This is excellent! Rep++ for you :)

This will probably come in very useful with ent detection because when its an ent the writing turns to yellow instead of blue.

n3ss3s

2008-04-05 14:34:53

Hehe, thanks, coming to think of it, yes, just doing like

Result := ChooseOptionEx(…) is shorter than moving the mouse on the tree, checking uptext and then right click etc or so.

:)

I took a new look at the Rev 15 one, it actually owns, but well… It doesn't have color! Mwuahaha!

Richard

2008-04-05 16:02:18

Lols.

If they didn't introduce this into the next rev, would you mind if I used it and credited you for it? Cos I might make a woodcutter after my current project :)

mastaraymond

2008-04-05 16:26:07

But option's can have different colors.. x)

Wizzup?

2008-04-05 16:46:15

From: Dude Richard
Lols.

If they didn't introduce this into the next rev, would you mind if I used it and credited you for it? Cos I might make a woodcutter after my current project :)


I don't see why you need chooseoption to return a color if you check for the uptext first?
Just do a quick findcolortolerance before your chooseoption, and see if you find a yellow color… (For the ent)

n3ss3s

2008-04-06 04:16:31

Well there it's really a discussion wether to be safe or safer, if you check uptext with findcolortolerance there is a chance someone said something in cyan or for yellow in normal.