SRL Archive - OSR Help

[Help]Creating my own Font


runw

2012-12-02 12:32:55

Ok, currently I'm experimenting with Simba and working towards making a mining bot for an rsps.

This thread caught my eye: http://villavu.com/forum/showthread.php?t=60451

So I gave it a shot in a hope to create the correct UpTexts for the rsps ingame.

My aim was to help Simba recognise the UpText Font when the mouse hovers over an iron ore rock: The UpText would be 'Mine Rocks / 3 more options'.

I created a new folder named 'RspsUpChars' and placed it in the directory: 'C:\Simba\Fonts'. Within this folder I have the individual .bmp files for the letters: M, i, n, e, R, o, c, k, s. I didn't feel the need to have every letter in the alphabet since I just want this to work for a mining bot.

Now, I'm assuming if I restart Simba that the fonts will load and be implemented into Simba.. so to test if my rsps UpText works I made this script:

program CheckFont;
{$i SRL\SRL.simba}

function CheckText:boolean;
var
X, Y: Integer;
begin
if FindObj(X, Y, [COLOR="Red"]'ine'[/COLOR], 1186611, 20) then [COLOR="Blue"]//Only using the UpText 'ine' in 'Mine' to test this[/COLOR]
begin
Mouse(X, Y, 5, 5, false); [COLOR="Blue"]//Right clicks the rock[/COLOR]
Mouse(X, Y+25, 5, 5, true); [COLOR="blue"]//Left clicks option 'Mine Rocks' (Later hope to use Option or WaitOption functions
if I can get a hang of creating fonts..)[/COLOR]
end;
end;

begin
CheckText;
end.

When I ran the script the mouse would search for the object and jump from rock to rock but never recognising the UpText.

At this point I took a look at the UpChars folder (in directory 'C:\Simba\Fonts') and noticed that the images had a red fill for the shadows of the letters. So I created a new set of bmp files for the letters 'M, i, n, e, R, o, c, k, s', this time including the shadows in a red fill (code = 255).

After running the script again, it's the same as before: the mouse will jump between rocks but never identifying the UpTexts and so never right clicking and left clicking the option to mine the rocks :(

I'd really appreciate if someone nudged me in the right direction, I'm new to Simba and scripting so for any help offered I give my thanks in advance :)

Oh and this is what my Bmps look like (rescaled heavily.. ^^):

EDIT: I took a good look at the Bpms that are already in Simba in the UpChars folder and found that they were all 14 pixels in height and had 3 pixels below the letter itself, so I did my Bpms of the rsps again and this is what it looks like:


Thanks to Wardancer who assisted me in IRC chat I found that I could use the GetTextAtExWrap function to show me what Simba was seeing in the UpText section (i.e. the top left corner of the client).

procedure GetText;
begin
Wait(5000);
writeln((ExtractFromStr((replace((lowercase(GetTextAtExWrap([COLOR="red"]0[/COLOR], [COLOR="red"]0[/COLOR], [COLOR="red"]90[/COLOR], [COLOR="Red"]25[/COLOR], [COLOR="Blue"]0[/COLOR], [COLOR="blue"]10[/COLOR], [COLOR="blue"]1[/COLOR], [COLOR="Green"]12896199[/COLOR], [COLOR="green"]50[/COLOR], [COLOR="DarkOrchid"]RspsUpChars[/COLOR]))), '.!', 'i')), Letters)));
end;

0, 0, 90, 25 - The coords where Simba will look for any text, 90 units across 25 down from top left corner of client screen covers the UpText area for 'Mine Rocks'.

0, 10, 1 - Spacing (I have no idea what the spacing is suppose to be or if it's even right).

12896199, 50 - The color and tolerance of the UpText (color I selected was the white/grey ish color in the UpText 'Mine' ingame.

RspsUpChars - The folder in directory 'C:\Simba\Fonts' where my Bmps are for the letters M, i, n, e, R, o, c, k, s.

Using this code I was able to move my mouse over the rocks to bring up the UpText 'Mine Rocks'. However in the debug box I was returned: 'scscn' and sometimes 'scsc' instead of 'Mine'. Has anyone got any idea what I'm suppose to do?

Edit: Fixed, used LoadFont(RspsUpChars, True); at the beginning of my GetText procedure before the wait and it worked :) Thank you Hobbit !

Rezozo

2012-12-02 12:51:18

Im not much, any, good with bitmaps and fonts. However, I am assuming that the bitmap you have should be black and white?
That makes most sense to me.
~Rez

runw

2012-12-02 12:54:31

From: Rezozo
Im not much, any, good with bitmaps and fonts. However, I am assuming that the bitmap you have should be black and white?
That makes most sense to me.
~Rez


Yes I did try this before filling the shadows in red, but it's the same result either way. I'm guessing I have yet to load/implement this new font into Simba.. but the tutorial wasn't clear how and I have no idea :/

Laimonas171

2012-12-02 13:07:15

From: runw
Yes I did try this before filling the shadows in red, but it's the same result either way. I'm guessing I have yet to load/implement this new font into Simba.. but the tutorial wasn't clear how and I have no idea :/


should bitmaps size be orignal font size? As i see at M it has 1 pixel from middle out (even if it's rescaled it should appear like that)

Rezozo

2012-12-02 13:19:37

What I mean is, should the text not be white? What ever you do not need, should be black, what you do need should be white. So background should be black, text white. No red.
~Rez

runw

2012-12-02 14:41:21

From: Laimonas171
should bitmaps size be orignal font size? As i see at M it has 1 pixel from middle out (even if it's rescaled it should appear like that)


Sorry I don't understand what is meant by "bitmaps size be original font size".. what is the original font size? And I'm not following you on the 1 pixel out from M. But yes this is rescaled but I tried my best to give a somewhat accurate representation of my bmps.

From: Rezozo
What I mean is, should the text not be white? What ever you do not need, should be black, what you do need should be white. So background should be black, text white. No red.
~Rez


You're right and this is how my bmps were first time when I tried (they were white letters with black background and no red) but the same thing happens, Simba wont recognise the rsps font.

Laimonas171

2012-12-02 15:27:02

From: runw
Sorry I don't understand what is meant by "bitmaps size be original font size".. what is the original font size? And I'm not following you on the 1 pixel out from M. But yes this is rescaled but I tried my best to give a somewhat accurate representation of my bmps.
.


selected area where pixels does't match, have no idea how to get that with recaling so it may cause problems thats. idk :D maybe not a big deal and it appeared after rescaling though

runw

2012-12-02 18:22:40

From: Laimonas171
selected area where pixels does't match, have no idea how to get that with recaling so it may cause problems thats. idk :D maybe not a big deal and it appeared after rescaling though


Ok I took a good look at the Bpms that are already in Simba in the UpChars folder and found that they were all 14 pixels in height and had 3 pixels below the letter itself, so I did my Bpms of the rsps again and this is what it looks like:


Markus

2012-12-02 18:29:12

C:\Simba\Fonts\UpCharsEx yw :)

Hobbit

2012-12-02 18:35:14

You need to actually load up the custom font or Simba will continue to use default.

See: http://docs.villavu.com/simba/scriptref/ocr.html

runw

2012-12-02 19:47:09

From: Hobbit
You need to actually load up the custom font or Simba will continue to use default.

See: http://docs.villavu.com/simba/scriptref/ocr.html


Thanks a lot dude! Works now :D

Rezozo

2012-12-02 22:01:45

Glad I wasn't able to help :p
Props guys, wawy to steaw my thundew :(
~Rez