SRL Archive - Include Development

uptext


Feroc1ty

2009-12-13 22:52:30

program test;

var
rscc:array of integer;

const
offset = 97;
uptext_x = 4;
uptext_y = 4;

type return = record
character:string;
x:integer;
end;





procedure loadfont();
var
i:integer;
path:string;

begin
path := AppPath + 'fonts\classiccharsold\';
SetArrayLength(rscc, 26);
for i := 0 to 25 do
rscc[i] := LoadBitmap(path + inttostr(i+offset) + '.bmp');
end;

function letter(x,y,x2,y2:integer):return;
var i,p,o,w:integer;
begin
for w := -1 to 16 do
begin
w := w + 1
i := -1;
repeat
i := i + 1;
until (i = 25) or FindBitmapMaskTolerance(rscc[i],p,o,x+w,y,x2+w,y2,0,200)
if i < 25 then
begin
result.character := Chr(97 + i);
if w > 10 then
result.character := ' ' + result.character;
result.x := p;
exit;
end;
end;
end;

function uptext():string;
var
t:return;
x:integer;
tm:integer;
begin
x := uptext_x;
tm := GetSystemTime();
repeat
t := letter(x,uptext_y,x+9,uptext_y+20);
if t.x = 0 then
exit;
if x = t.x + 1 then
exit;
x := t.x + 1;
result := result + t.character;
until ((tm + 1000) < GetSystemTime);
end;


begin
loadfont;
writeln(uptext);
end.

this won't work unless the rsc client is targetted and the very top left of rsc screen is at 0,0 coords

edit: i dunno wut happen but it dun work nemore gonna try to fix lol had it working half an hour ago

Sex

2009-12-13 23:54:34

Post when you have fixed it and I'll commit it but I think that normal text finding would work..I'll have to do some testing.

Feroc1ty

2009-12-14 17:38:53

The function itself works flawlessly, it's just that my coordinates are off.

Awkwardsaw

2009-12-14 17:42:07

i <3 you. :)

when i finish my current projects, i'll start to work on an epic rsc script, now that uptext is (hopefully) fix'd. :D

although i also think just using findtext would work just as well.. our only problem was loading the rsc fonts lol

Feroc1ty

2009-12-14 18:50:52

i tried using the findtext but failed so ended up making this, and im not sure if there is an issue in this code or in my current script that uses this include but it wont work, ill get this shit figured out and complete by tommorow, so start making your script as if uptext was working :D

weequ

2009-12-15 07:18:09

GetTextAtEx(382, 2, 0, Charsrsc, false, false, 0, 1, -1, 100, true, tr_NormalChars);
You have to change 382 and Charsrsc.

Feroc1ty

2009-12-15 17:57:30

From: antti mies
GetTextAtEx(382, 2, 0, Charsrsc, false, false, 0, 1, -1, 100, true, tr_NormalChars);
You have to change 382 and Charsrsc.


Saved me 10 minutes trying to fix mine up, thx, works perfectly.