Spiker
2012-05-17 20:31:11
Recently, after thinking about my friend's java program which read a website for real-time stock prices, I figured since I made a summoning script with scroll support and was constantly checking scroll profits that I should do the same thing in Simba but for summoning scrolls' profits.
It probably isn't the best way to program this task, but it works. :spot:
More functions/procedures to come. :)
Outputs in order:
Note: Thank you Tootoot222 for answering my abundance of questions.
It probably isn't the best way to program this task, but it works. :spot:
More functions/procedures to come. :)
Program ScrollsProfits;
Const
ScrollType = 'Ambush';
Function GetScrollProfit(Scroll:string):String;
Var
Words:String;
Index, Index1:Integer;
begin
Words := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
Index := PosEx('>', Words, PosEx('color:', Words, Pos(Scroll, Words))+6);
Index1 := PosEx('<', Words, Index);
Result := ScrollType + ' Scroll Profit: ' + Copy(Words, Index+1, PosEx('<', Words, Index)-(Index+1)) + 'gp';
end;
Procedure DisplayAllScrolls; //Displays all scrolls, their required summoning levels, their corresponding pouches, and their profits/losses
Var
Page, Scroll, Level, Pouch, Profit:String;
Index, Index1, i:Integer;
begin
Writeln('|==============================================================|');
Writeln('| Scroll Level Pouch Profit |');
Writeln('|==============================================================|');
Page := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
For i := 0 to 41 Do
begin
Index := PosEx('name="', Page, Pos('Profit', Page)+(i*1230));
Index1 := PosEx('.p', Page, Index+10);
Scroll := Copy(Page, Index+6, Index1-(Index+6));
If Pos('Titan', Scroll) <> 0 Then
Scroll := 'Titan''s con. scroll';
Level := Copy(Page, PosEx('scroll</a> </td><td> ', Page, Index)+21, 2);
Pouch := Copy(Page, PosEx('name="', Page, Index+4)+6, PosEx('.p', Page, PosEx('name="', Page, Index+4)+6)-(PosEx('name="', Page, Index+4)+6));
Index1 := PosEx('<', Page, PosEx('color', Page, PosEx('name', Page, Index)));
Profit := Copy(Page, PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1, Index1-(PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1)) + 'gp';
Writeln(' ' + Scroll + ' ' + Level + ' ' + Pouch + ' ' + Profit);
end;
end;
Procedure DisplayPositiveProfitScrolls; //Displays scrolls' names, required levels, corresponding pouches, and profits if they can make a profit
Var
Page, Scroll, Level, Pouch, Profit, Comma:String;
Index, Index1, i:Integer;
begin
Writeln('|==============================================================|');
Writeln('| Scroll Level Pouch Profit |');
Writeln('|==============================================================|');
Page := GetPage('http://runescape.wikia.com/wiki/Calculator:Summoning/Scrolls/High');
Comma := ',';
For i := 0 to 41 Do
begin
Index := PosEx('name="', Page, Pos('Profit', Page)+(i*1230));
Index1 := PosEx('.p', Page, Index+10);
Scroll := Copy(Page, Index+6, Index1-(Index+6));
If Pos('Titan', Scroll) <> 0 Then
Scroll := 'Titan''s con. scroll';
Level := Copy(Page, PosEx('scroll</a> </td><td> ', Page, Index)+21, 2);
Pouch := Copy(Page, PosEx('name="', Page, Index+4)+6, PosEx('.p', Page, PosEx('name="', Page, Index+4)+6)-(PosEx('name="', Page, Index+4)+6));
Index1 := PosEx('<', Page, PosEx('color', Page, PosEx('name', Page, Index)));
Profit := Copy(Page, PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1, Index1-(PosEx('>', Page, PosEx('color', Page, PosEx('name="', Page, Index)))+1)) + 'gp';
If Pos('-', Profit) = 0 Then
begin
If Pos(Comma, Profit) > 0 Then
Delete(Profit, Pos(Comma, Profit), 1);
Writeln(' ' + Scroll + ' ' + Level + ' ' + Pouch + ' ' + Profit);
end;
end;
end;
begin
Writeln(GetScrollProfit(ScrollType));
DisplayAllScrolls;
DisplayPositiveProfitScrolls;
end.Outputs in order:
Ambush Scroll Profit: 454gp|================================|
| Scroll Level Pouch Profit |
|================================|
Tireless run scroll 52 Spirit terrorbird pouch -89gp
Abyssal drain scroll 54 Abyssal parasite pouch -1,227gp
Dissolve scroll 55 Spirit jelly pouch -627gp
Steel bull rush scroll 56 Steel minotaur pouch -502gp
Fish rain scroll 56 Ibis pouch -415gp
Ambush scroll 57 Spirit kyatt pouch 454gp
Rending scroll 57 Spirit larupia pouch -753gp
Goad scroll 57 Spirit graahk pouch -6,667gp
Doomsphere scroll 58 Karam. overlord pouch -566gp
Dust cloud scroll 61 Smoke devil pouch -789gp
Abyssal stealth scroll 62 Abyssal lurker pouch 842gp
Oph. incubation scroll 63 Spirit cobra pouch 407gp
Poisonous blast scroll 64 Stranger plant pouch -533gp
Mith bull rush scroll 66 Mithril minotaur pouch -657gp
Toad bark scroll 66 Barker toad pouch -203gp
Testudo scroll 67 War tortoise pouch -8,365gp
Swallow whole scroll 68 Bunyip pouch -198gp
Fruitfall scroll 69 Fruit bat pouch 257gp
Famine scroll 70 Ravenous locust pouch 45gp
Arctic blast scroll 71 Arctic bear pouch -232gp
Volcanic str. scroll 73 Obsidian golem pouch -799gp
Crushing claw scroll 74 Granite lobster pouch -744gp
Mantis strike scroll 75 Praying mantis pouch -802gp
Inferno scroll 76 Forge regent pouch -663gp
Adamant bull rush scroll 76 Adamant minotaur pouch -405gp
Deadly claw scroll 77 Talon beast pouch -571gp
Acorn missile scroll 78 Giant ent pouch -716gp
Titan's con. scroll 79 Fire titan pouch 239gp
Titan's con. scroll 79 Ice titan pouch -5,685gp
Titan's con. scroll 79 Moss titan pouch 215gp
Regrowth scroll 80 Hydra pouch -538gp
Spike shot scroll 83 Spirit dagannoth pouch -45gp
Ebon thunder scroll 83 Lava titan pouch -917gp
Swamp plague scroll 85 Swamp titan pouch -731gp
Rune bull rush scroll 86 Rune minotaur pouch -58gp
Healing aura scroll 88 Unicorn stallion pouch 365gp
Boil scroll 89 Geyser titan pouch -888gp
Magic focus scroll 92 Wolpertinger pouch 60gp
Essence shipment scroll 93 Abyssal titan pouch -226gp
Iron within scroll 95 Iron titan pouch -17gp
Winter storage scroll 96 Pack yak pouch 330gp
Steel of legends scroll 99 Steel titan pouch 578gp|================================|
| Scroll Level Pouch Profit |
|================================|
Ambush scroll 57 Spirit kyatt pouch 454gp
Abyssal stealth scroll 62 Abyssal lurker pouch 842gp
Oph. incubation scroll 63 Spirit cobra pouch 407gp
Fruitfall scroll 69 Fruit bat pouch 257gp
Famine scroll 70 Ravenous locust pouch 45gp
Titan's con. scroll 79 Fire titan pouch 239gp
Titan's con. scroll 79 Moss titan pouch 215gp
Healing aura scroll 88 Unicorn stallion pouch 365gp
Magic focus scroll 92 Wolpertinger pouch 60gp
Winter storage scroll 96 Pack yak pouch 330gp
Steel of legends scroll 99 Steel titan pouch 578gpNote: Thank you Tootoot222 for answering my abundance of questions.