SRL Archive - OSR Help

AIO Support?


koryperson

2013-12-06 00:24:16

So I know I've asked so many questions recently, but that's because I've watched like 50000 tutorials and my brain is pumping and I'm getting excited about learning new scripting shiz. A HUGE advance in my scripts would be adding AIO support, atm I have no clue how to do this. What I'd like to do is somewhere at the top of the script, in the setup section, have like, "fish := ____" and whatever is typed in is matched to a certain portion of the script to catch said fish.

I'm in need of this for an alcher to add support for multiple items. I know this is probably something really, really simple to you pro scripters, but any help would be much appreciated, thanks!

Ian

2013-12-06 00:31:51

An easy way of adding AIO support is through cases.

At the top of the script, you'd have a constant like this:

const
RockToMine = 'Tin'; //Put the rock you want to mine here!
And then when you want to mine you can use a case statement like this:

const
begin
case lowercase(RockToMine) of
'copper': MineCopper;
'tin': MineTin;
'iron': MineIron;
end;
end;

You can also store information in arrays and load it, although this method is more compicated.


procedure loadInfo;
begin
case lowercase(Bar) of { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 }
{ Ore1BMP, Ore2BMP, BarBMP, Ore1Name, Ore2Name, Ore1ID, Ore2ID, BarID XP Ore1Amt Ore2Amt Ore1AmtCB Ore2AmtCB Ore1AmtBar Ore2AmtBar CoalBag }

'bronze': SmeltInfo := [TinOreBMP, CopperOreBMP, BronzeBarBMP, 'in ore', 'opper ore', 438, 436, 2349, 6.2, 14, 14, -1, -1, 1, 1, False];
'iron': SmeltInfo := [IronOreBMP, 0, IronBarBMP, 'ron ore', '', 440, 0, 2351, 12.5, 28, -1, -1, -1, 1, 0, False];
'silver': SmeltInfo := [SilverOreBMP, 0, SilverBarBMP, 'lver ore', '', 442, 0, 2355, 13.7, 28, -1, -1, -1, 1, 0, False];
'steel': SmeltInfo := [IronOreBMP, CoalOreBMP, SteelBarBMP, 'ron ore', 'oal', 440, 453, 2353, 17.5, 9, 0, 18, 0, 1, 2, True];
'gold': SmeltInfo := [GoldOreBMP, 0, GoldBarBMP, 'old ore', '', 444, 0, 2357, 22.5, 28, -1, -1, -1, 1, 0, False];
'mithril':SmeltInfo := [MithrilOreBMP, CoalOreBMP, MithrilBarBMP, 'ril ore', 'oal', 447, 453, 2359, 30.0, 5, 0, 10, 0, 1, 4, True];
'adamant':SmeltInfo := [AdamantiteOreBMP, CoalOreBMP, AdamantBarBMP, 'antite ore', 'oal', 449, 453, 2361, 37.5, 4, 0, 7, 0, 1, 6, True];
'rune': SmeltInfo := [RuniteOreBMP, CoalOreBMP, RuneBarBMP, 'unite ore', 'oal', 451, 453, 2363, 50.0, 3, 0, 6, 0, 1, 8, True];
end;
end;

koryperson

2013-12-06 00:35:38

From: BMWxi
An easy way of adding AIO support is through cases.

At the top of the script, you'd have a constant like this:

const
RockToMine = 'Tin'; //Put the rock you want to mine here!
And then when you want to mine you can use a case statement like this:

const
begin
case lowercase(RockToMine) of
'copper': MineCopper;
'tin': MineTin;
'iron': MineIron;
end;
end;

You can also store information in arrays and load it, although this method is more compicated.


procedure loadInfo;
begin
case lowercase(Bar) of { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 }
{ Ore1BMP, Ore2BMP, BarBMP, Ore1Name, Ore2Name, Ore1ID, Ore2ID, BarID XP Ore1Amt Ore2Amt Ore1AmtCB Ore2AmtCB Ore1AmtBar Ore2AmtBar CoalBag }

'bronze': SmeltInfo := [TinOreBMP, CopperOreBMP, BronzeBarBMP, 'in ore', 'opper ore', 438, 436, 2349, 6.2, 14, 14, -1, -1, 1, 1, False];
'iron': SmeltInfo := [IronOreBMP, 0, IronBarBMP, 'ron ore', '', 440, 0, 2351, 12.5, 28, -1, -1, -1, 1, 0, False];
'silver': SmeltInfo := [SilverOreBMP, 0, SilverBarBMP, 'lver ore', '', 442, 0, 2355, 13.7, 28, -1, -1, -1, 1, 0, False];
'steel': SmeltInfo := [IronOreBMP, CoalOreBMP, SteelBarBMP, 'ron ore', 'oal', 440, 453, 2353, 17.5, 9, 0, 18, 0, 1, 2, True];
'gold': SmeltInfo := [GoldOreBMP, 0, GoldBarBMP, 'old ore', '', 444, 0, 2357, 22.5, 28, -1, -1, -1, 1, 0, False];
'mithril':SmeltInfo := [MithrilOreBMP, CoalOreBMP, MithrilBarBMP, 'ril ore', 'oal', 447, 453, 2359, 30.0, 5, 0, 10, 0, 1, 4, True];
'adamant':SmeltInfo := [AdamantiteOreBMP, CoalOreBMP, AdamantBarBMP, 'antite ore', 'oal', 449, 453, 2361, 37.5, 4, 0, 7, 0, 1, 6, True];
'rune': SmeltInfo := [RuniteOreBMP, CoalOreBMP, RuneBarBMP, 'unite ore', 'oal', 451, 453, 2363, 50.0, 3, 0, 6, 0, 1, 8, True];
end;
end;



Thanks man, I knew it'd be simple, just couldn't figure it out!


EDIT: Actually…. Whenever I try to use it, it I get 'Identifier Expected'

I've never used Case before so idk lol….

const
begin
case lowercase(ItemToAlch) of
'arrow': AlchArrow;
'cannonball': AlchCannonBall;
'log': AlchLog;
'bolt': AlchBolt;
End;
End;

koryperson

2013-12-06 01:39:14

Couldn't get the one you posted to work… So I made it 'less basic' and for some reason it works…

I know it looks a lot sloppier, but if someone could tell me why the other didn't work it'd be awesome :)

Procedure WhichItem;

Begin

if Lowercase(ItemToAlch) = 'arrows' then
AlchArrows;

if Lowercase(ItemToAlch) = 'cannonballs' then
AlchCannonBalls;

if Lowercase(ItemToAlch) = 'logs' then
AlchLogs;

if Lowercase(ItemToAlch) = 'bolts' then
AlchBolts;

End;

Flight

2013-12-06 02:09:50

You'll find these helpful:
Learn to use Cases!
Using Records in your Scripts