SRL Archive - Help and Support

function GetTreeExp(TreeName: string): Extended;


Jagex_Fagex

2007-06-28 22:21:26

Ok, im trying to use this in my script. I have a variable TreeType which is assigned a number depending on what tree it will be cutting.

I am trying to use Case to tell it what TreeName is

procedure GetWoodCutXp;
begin
case TreeType of
1 : xp:= 'tree';// <--- Xp Per Normal Log !
2 : xp:= 37;// <--- Xp Per Oak Log !
3 : xp:= 67;// <--- Xp Per Willow Log ! (
4 : xp:= 100;// <--- Xp Per Maple Log ! ( Must Change THE 0 TO the xp given)
5 : xp:= 175;// <--- Xp Per Yew Log !
6 : xp:= 200;// <--- Xp Per Magic Log !
end;
end;

i know i have to change "xp" to something else. I have tried everything i can think of, Is it possible? how is it done? thanks :D I may think of it soon, im just having a mental block today.

EDIT:
procedure GetWoodCutXp;
begin
case TreeType of
1 : Begin
GetTreeExp('tree');
end;
2 : Begin
GetTreeExp('oak');
end;
3 : Begin
GetTreeExp('willow');
end;
4 : Begin
GetTreeExp('maple');
end;
5 : Begin
GetTreeExp('mahogany');
end;
6 : Begin
GetTreeExp('yew');
end;
7 : Begin
GetTreeExp('magic');
end;
end;
end;

Would that be it?

JAD

2007-06-28 23:47:13

You don't have any parameter to have the user set what to do. And you need it to result to the function. You'd want to do something like:


function GetWoodCutExp(WhichTree: String): Integer;
begin
case LowerCase(WhichTree) of
'tree', 'trees': Result := 25;
'oak', 'oaks': Result := 37;
'willow', 'willows': Result := 67;
'maple', 'maples': Result := 100;
'yew', 'yews': Result := 175;
'magic', 'magics': Result := 200;
end;
end;

Sorry to make the whole function like that for you… :p But here's how you could use it easily in a script then:


procedure ProgressReport;
var TheExp: Integer;
begin
TheExp := GetWoodCutExp('yew') * Loads;
Writeln(IntToStr(TheExp));
end;

Of course, Loads would be a variable you added to when chopping or whatever :p

Hope I made sense and that was what you were looking for, or I helped at all :)

Bobarkinator

2007-06-28 23:59:06

{.include SRL/SRL/misc/FindXP.scar}
;) Abyssal, Smartz and I made that over the course of a few days.

Jagex_Fagex

2007-06-29 00:00:12

ok, this is what i got, im pretty sure it's close to yours.

procedure GetTreeName;
begin
case TreeType of
1 : Name:='tree';
2 : Name:='oak';
3 : Name:='willow';
4 : Name:='maple';
5 : Name:='mahogany';
6 : Name:='yew';
7 : Name:='magic';
end;
end;

Procedure CheckReprt;
Begin
Writeln('|~~~~~~~~~~~~~~~PowerCutter by Fultron Scripting (a.k.a Jagex_Fagex)~~~~~~~~~~~~~~~|')
Writeln('| You Have Gained '+ floattostr(GetTreeExp(Name)*LogsCut) +' Exp |')
Writeln('|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|')
end;
end;

NewToAutoing

2007-06-29 01:15:28

No..that won't work. If it would even compile, it would be trying to multiply the term "oak" or whatever, by the amount of logs that were cut. But it woudln't even make it that far, as TreeType isn't defined as anything (unless you have it somewhere higher in your script) And either way, it doesn't return the xp, only the name of the tree. The way JAD posted is pretty much the best way it can be done, though i'm guessing you don't understand how he did it since yours wouldn't work and yet you think it's close to his..?

program New;
{.include SRL/SRL.scar}

var
LogsCut: Integer; //You'd be using this differently, but i put it
//so that it will compile in this example.
const
Tree = 'oak'; //Change this around to see how it works. In your script
//You probably wouldn't do it this way.

function GetWoodCutExp(WhichTree: String): Integer;
begin
case LowerCase(WhichTree) of
'tree', 'trees': Result := 25;
'oak', 'oaks': Result := 37;
'willow', 'willows': Result := 67;
'maple', 'maples': Result := 100;
'yew', 'yews': Result := 175;
'magic', 'magics': Result := 200;
end;
end;

Procedure CheckReport;
Begin
Writeln('|~~~~~~~~~~~~~~~PowerCutter by Fultron Scripting (a.k.a Jagex_Fagex)~~~~~~~~~~~~~~~|');
Writeln('| You Have Gained '+ IntToStr(GetWoodCutExp(Tree)*LogsCut) + ' Exp From ' + Tree + ' |');
Writeln('|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|');
end;

begin
LogsCut := 64; //Random number, so that you can see how this works.
SetUpSRL;
CheckReport;
end.

Try that, mess around with it until you understand :) I just put your progress report with JADs function, and threw it together so that it would work on it's own. Perhaps that'll help you understand?

Jagex_Fagex

2007-06-29 07:33:57

um.. you obviously don't know what GetTreeExp is? didn't think so.. All i need is to call GetTreeName; and it works.

Mine may not be close to his, but it works, and less coding :)

just as a side note - I've been scripting for around 3 years now with a break in between. I think i know how to script ;)

Santa_Clause

2007-06-29 07:51:26

Ahh Jagex. No hard feelings dude. If he offended you, I'm sure it's by accident. I talk to him alot.

JAD

2007-06-29 10:58:39

Lol, I was trying my best when typing my message to not sound like I was talking down to you, because I knew how experienced you were with scripting and how less experienced I was :p

Anyways, I didn't know you were trying to use FindExp like that so I just made my own there :p

And yes, yours works good.

NewToAutoing

2007-06-29 18:03:45

Sorry :redface: I saw GetTreeName, and GetTreeXp and assumed it was a typo. And since JAD didn't use GetTreeXp, that led me to believe i was right in believing it was a typo. In that case, you don't need get tree name if you use a string to identify which tree rather than an integer, i think. Meaning you could get do GetTreeXp(TreeType). Sorry if i seemed rude, i just saw the max longevity and the middle-ish activity and viewed it as accepted when everyone was accepted, which was ignortant and i shouldn't have done that. And yeah, i didn't know what GetTreeXp did. So once again sorry :redface:

Jagex_Fagex

2007-06-29 22:35:57

ah, ok, no worries then, but if i use a string, then there is the matter of tree, trees, normal, blah blah.. means more coding :P

Abyssal

2007-06-29 23:27:47

From: bobarkinator
ScarScript:By Drunkenoldma [LEFT]{.include SRL/SRL/misc/FindXP.scar} [/LEFT]

;) Abyssal, Smartz and I made that over the course of a few days.




Amen :D
Lots of hard work in there :o