SRL Archive - General Botting Help

Getting the paint from pastebin


Spaceblow

2014-10-01 09:23:10

So I'm adjusting my script and I want to make it look cleaner. My idea is to get the paint bitmap from pastebin but unfortunately, I can't get it to work. This is what I have:

function getPaint(): string;
var
pastebinPage, paint: string;

begin
pastebinPage := getPage('http://pastebin.com/raw.php?i=Phph4XT2');
paint := between('paintstart', 'paintend', pastebinPage);
result := paint;
end;

procedure proggyPaint();
begin
PaintBmp := BitmapFromString(575, 175, getPaint());

smartImage.drawBitmap(PaintBMP, point(1, 382));
smartImage.drawText(timeRunning, point(315, 420), 'UpCharsEx', true, 16645629);
smartImage.drawText(groupDigits(redberriesGot, ',') + ' (' + groupDigits(loadsDone, ',') + ' loads)', point(315, 460), 'UpCharsEx', true, 1252480);
smartImage.drawText(groupDigits(profit, ',') + ' (PH: ' + groupDigits(profitPerHour, ',') + ')', point(315, 500), 'UpCharsEx', true, 2207709);
end;

So it has to get the text between 'paintstart' and 'paintend' from this link and then turn it into the paint. But instead of that, it gives me nothing, does anyone know what I'm doing wrong? I appreciate all the help, thanks in advance! :)

Turpinator

2014-10-01 10:40:07

to make it so that the script doesnt constantly have to grab the bitmap from the page, id suggest just downloading it locally, then displaying it.

like this…
procedure checkForImages(path, link, item: string);
var
progFile: longInt;
picName: string;

begin
picName := AppPath + path;

try
if not fileExists(picName) then
begin
writeLn('NOTIFICATION: ' + item + ' does not exist - Downloading it now!');
progFile := createFile(picName);
end else
begin
writeLn('NOTIFICATION: ' + item + ' already exists!');
exit;
end;

closeFile(progFile);

progFile := rewriteFile(picName, false);
writeFileString(progFile, getPage(link));
writeLn('NOTIFICATION: ' + item + ' has been download to Simba folder!');
writeLn('');
finally
if (progFile > 0) then
closeFile(progFile);
end;
end;
i just stole from one of @The Mayor's scripts.

Mark

2014-10-01 11:44:51

well i cant test right now but as i can see your problem is the padding i think could be wrong but try and do te same but remove the padding from the pastebin
so it just one whole section without plus and quotes + ''

Turpinator

2014-10-01 13:43:59

From: Mark
well i cant test right now but as i can see your problem is the padding i think could be wrong but try and do te same but remove the padding from the pastebin
so it just one whole section without plus and quotes + ''


Yeah this is the problem. i didnt even bother to look at the pastebin, i just assumed it was correct.

so your string that youre attempting it load is actually
'meJzsfQeUHMXR/9Pm2ZzT7N3t' +
'3UqncMoZSQgdKAEiiJwMBgMGDJhs+EwwGGPANjiBjcE2YDC2sZAFJ' +
'pogTJCJBpMMf8AkEU0yH+HD3Hv/X3fN1NbO7h2HsmD6ze2bm+np6a' + ...
(including all the single quotes and pluses)

so what you need to do is open the bitmap conversion and deselect the pad output.

then youll get something like
 bmp := 'h97f8s89hfds...';
so in your pastebin, simply make it h97f8s89hfds… without the single quotes.
and then you wont need to do the 'between' func

Spaceblow

2014-10-02 15:03:32

I'm sorry for my late reply, I didn't have much time yesterday. I really appreciate your help, thank you guys!

From: Turpinator
to make it so that the script doesnt constantly have to grab the bitmap from the page, id suggest just downloading it locally, then displaying it.

like this…
I appreciate your help but it wasn't what I was looking for. I actually don't really like to let the script download something on the user's computer. I find it some kind of sneaky, even if it's for something good. :p

From: Mark
well i cant test right now but…
This was the answer I was looking for, thank you very much!

From: Turpinator
Yeah this is the problem

Thank you very much for the detailed explanation, you helped me a lot! But now I'm wondering something… If I use:

PaintBmp := BitmapFromString(575, 175, 'ze3fs3e5f1c38vg...');  

then it makes a bitmap from that string.

And if I use:

PaintBmp := BitmapFromString(575, 175, getPaint());  

then it runs the getPaint() function. So it's kind of comparable to a constant, it stores all the info on pastebin.

So you can see in the first snippet it uses 'ze3fs3e5f1c38vg…' and from pastebin it takes ze3fs3e5f1c38vg…. So it doesn't have any quotation marks. When I upload the string to pastebin including quotation marks (at the beginning & end), it gives me no bitmap. Why is this so? So I see getPage as a placeholder for the string, but then why doesn't it work when I upload the string with quotation marks? I mean, if I don't use getPage and simply put in 'ze3fs3e5f1c38vg…', then I do need those marks. Why? I hope my question is clear enough for you to understand because remember, English isn't my native language. If you don't get what I'm saying, please tell me, I won't feel offended. :)

bonsai

2014-10-02 18:23:37

From: Spaceblow
I actually don't really like to let the script download something on the user's computer. I find it some kind of sneaky, even if it's for something good. :p


I agree with your sentiment there (even though my published script does access the web for updates and data).

But you want to download it from pastebin over the web which is not really any different than downloading it from anyplace else like github. ??

Re: the strings, here's the deal.

var myString: string;
myString := 'Let it begin';

myString contains the data Let it begin

The very string itself does not have quotes. Just the data. It has other complexities but we can ignore them for the moment.

But… how is the compiler supposed to know? Check this out:


myString := Let it begin;

Do you see the issue there? The word begin is a problem just floating around there. The compiler can't tell the difference between the keywords and your string.

So when we type the string in, we use quotes. But only when we type it in.

When you assign a string from another string or from a string function you do not need any quotes.


myString := download();
newString := myString;

In your specific example:
PaintBmp := BitmapFromString(575, 175, getPaint());

If you do this the normal way, you need to type in the string. So you would need quotes.

But remember, BitmapFromString wants a string for that parameter. The DATA, which has no quotes. You only used the quotes to make sure the compiler didn't do stupid things.

So when you change it to a function call, which returns a string, you don't need to play any quotation games.

Make sense?

Turpinator

2014-10-02 19:44:03

From: Spaceblow
So you can see in the first snippet it uses 'ze3fs3e5f1c38vg…' and from pastebin it takes ze3fs3e5f1c38vg…. So it doesn't have any quotation marks. When I upload the string to pastebin including quotation marks (at the beginning & end), it gives me no bitmap. Why is this so? So I see getPage as a placeholder for the string, but then why doesn't it work when I upload the string with quotation marks? I mean, if I don't use getPage and simply put in 'ze3fs3e5f1c38vg…', then I do need those marks. Why? I hope my question is clear enough for you to understand because remember, English isn't my native language. If you don't get what I'm saying, please tell me, I won't feel offended. :)


From: Turpinator

then youll get something like
 bmp := 'h97f8s89hfds...';
so in your pastebin, simply make it h97f8s89hfds… without the single quotes.
and then you wont need to do the 'between' func


so in your pastebin, simply make it h97f8s89hfds… without the single quotes.


and that should solve the issue.

and as bonsai as so eloquently stated…

From: bonsai
The DATA, which has no quotes. You only used the quotes to make sure the compiler didn't do stupid things.

So when you change it to a function call, which returns a string, you don't need to play any quotation games.


(recap)
the quotes tell the compiler/simba that it is a string. if you have already defined something as a string (ie a func), you dont need to tell it again. because then it just does not what you want.

Spaceblow

2014-10-03 05:45:11

From: bonsai
I agree with your sentiment there (even though my published script does access the web for updates and data).

But you want to download it from pastebin over the web which is not really any different than downloading it from anyplace else like github. ??
Well, it's just a harmless string. I just don't really like the fact that if the player runs the script, it downloads multiple files on the hard disk. I actually prefer to manually download files for a script than let it do it for me. Maybe my opinion will change, who knows.

From: bonsai

Make sense?

From: Turpinator
(recap)
the quotes tell the compiler/simba that it is a string. if you have already defined something as a string (ie a func), you dont need to tell it again. because then it just does not what you want.
This makes so much sense, thank you very much, both of you!