Log in

View Full Version : Creating a Option for my script?



ffcfoo
07-14-2010, 03:55 PM
Hello, well I got a Fletching script that I made and I was going to add a option for different types of logs to cut so I was going to do this:

procedure LogsToCut;
begin
if LogsType := 'Willow' then
Do WillowCut;
end;

Then add LogsType := 'Willow' In the declare players. Then I would just create a bunch of procedures for each log. But I do not know if this will work because I just made this up and I do not know if that procedure will even work. Also I want to know if there is a better way to do something like this.

Dgby714
07-14-2010, 04:05 PM
well Players is a type that doesn't include "LogsType" in it so you can use "Strings[0]" instead so here

Your declare players will look something like this

procedure DeclarePlayers;
begin
with Players[0] do
begin
... //other players crap like nick and pass
Strings[0] := 'Willow'; //Logtype here =)
... // maybe some other varables
end;
end;

then too use that "Strings[0]" you can do


case LowerCase(Players[CurrentPlayer].Strings[0]) of
'willow', 'willows': CutWillows;
'someothertree', 'alias': CutOtherTree;
else
CutTheElseTree;
end;

Updated to case because of Frements post =)

Frement
07-14-2010, 04:08 PM
case Players[CurrentPlayer].Strings[0] of
...
end;

Use cases.

ffcfoo
07-14-2010, 04:18 PM
well Players is a type that doesn't include "LogsType" in it so you can use "Strings[0]" instead so here

Your declare players will look something like this

procedure DeclarePlayers;
begin
with Players[0] do
begin
... //other players crap like nick and pass
Strings[0] := 'Willow'; //Logtype here =)
... // maybe some other varables
end;
end;

then too use that "Strings[0]" you can do


case LowerCase(Players[CurrentPlayer].Strings[0]) of
'willow', 'willows': CutWillows;
'someothertree', 'alias': CutOtherTree;
else
CutTheElseTree;
end;

Updated to case because of Frements post =)

"CutTheElseTree;" What? Why would you cut a tree that has already been listed? Wouldn't be:

case LowerCase(Players[CurrentPlayer].Strings[0]) of
'willow', 'willows': CutWillows;
'someothertree', 'alias': CutOtherTree;
else
TerminateScript;
end;

Also it would look like this correct?:

procedure KindOfLogs;
begin
if not LoggedIn then Exit;
case LowerCase(Players[CurrentPlayer].Strings[0]) of
'tree', 'trees': CutTrees;
'oak', 'oaks': CutOaks;
'willow', 'willows': CutWillows;
'maple', 'maples': CutMaples;
'yew', 'yews': CutYews;
'magic', 'magics': CutMagics;
else
TerminateScript;
end;
end;

Dgby714
07-14-2010, 04:35 PM
Yes and you can add as many aliases as you need =)

like for a normal tree it could be


'tree', 'trees', 'normal': CutTrees;

and yes you can put anything in the else thing, I just make it cut normal trees if people don't set it. (I also add a little warning that they didn't set it!)

ffcfoo
07-14-2010, 05:20 PM
Yes and you can add as many aliases as you need =)

like for a normal tree it could be


'tree', 'trees', 'normal': CutTrees;

and yes you can put anything in the else thing, I just make it cut normal trees if people don't set it. (I also add a little warning that they didn't set it!)

Okay I understand.