SRL Archive - Research & Development Lounge

My FindLevel procedure


Bad Processor

2009-01-21 12:58:21

Hey everyone. I feel I do not contribute enough to SRL itself. Sometimes I feel I am useless in certain things. So I decided to pull myself together and make a function which could make scripting that little bit easier. I just hope it hasn't been implemented already. The idea is this:

You have a script, and want to check a level hasn't leveled up. You have two point in your script:

1. the marker
2. a point where you want to check if a skill, eg. cooking, has leveled up the marker.

So, my idea is to make this slightly easier. Here is my code (feel free to use the list of skills in your script, or check if a curse\whatever has lowered your skill), also made to look like it is inside SRL:

var OldSkills: array [1..24] of Integer;
var SkillList: array [1..24] of string;

{*******************************************************************************
procedure SetupSkillList;
By: BadProcessor
Description: Use to setup everything.
*******************************************************************************}

procedure SetupSkillList;
var Forl: Integer;
begin
SkillList[1]:='attack';
SkillList[2]:='strength';
SkillList[3]:='ranged';
SkillList[4]:='magic';
SkillList[5]:='defence';
SkillList[6]:='craft';
SkillList[7]:='hp';
SkillList[8]:='pray';
SkillList[9]:='agility';
SkillList[10]:='herblore';
SkillList[11]:='thief';
SkillList[12]:='fish';
SkillList[13]:='runecraft';
SkillList[14]:='slay';
SkillList[15]:='farm';
SkillList[16]:='mine';
SkillList[17]:='smith';
SkillList[18]:='hunt';
SkillList[19]:='cook';
SkillList[20]:='fire';
SkillList[21]:='wc';
SkillList[22]:='fletch';
SkillList[23]:='construction';
SkillList[24]:='summoning';
for Forl:= 1 to 24 do begin
OldSkills[Forl]:= GetSkillLevel(SkillList[Forl]);
end;
end;

{*******************************************************************************
function FindLevelUp(SkillName:String): Boolean;
By: BadProcessor
Description: Checks if the selected skill has leveled up since the last call of
SetupSkillList.
*******************************************************************************}

function FindLevelUp(SkillName:String): Boolean;
var SkillNumber,Forl: Integer;
begin
SetupSkillList;
for Forl:= 1 to 24 do begin
if SkillName = SkillList[Forl] then begin
SkillNumber:= Forl;
end;
end;
if GetSkillLevel(SkillNumber) >= OldSkills[SkillNumber] then begin
Result:= True;
end;
end;

Sorry if this isn't good enough. Maybe I just don't have the potential to make good things yet.:(
Please comment,

– BadProcessor

Edit: Oh Yeah, forgot to mention:

Use SetupSkillList at point 1
FindLevelUp at point 2

Cazax

2009-01-21 13:00:54

GetAllLevels does the same as your first function.

Floor66

2009-01-21 13:13:04

Fix indentation.

Bad Processor

2009-01-21 13:19:28

Great. So that was a waste of time. That is the way I think it should be indented to. 1 space for every begin\end. Oh well, I knew it wasn't good enough. Sorry.

– BadProcessor

Floor66

2009-01-21 13:47:21

Don't get all down now!
That it already exists doesn't mean urs SUCK!
I'm just making a remark that indentation should be 2 spaces.

It's good practice!

Bad Processor

2009-01-22 15:23:07

Hey, does GetAllLevels check if you have leveled up yet? Just looked at the code, I don't think it does. Nevermind, FindLevelUp will never make SRL anyway.

– BP

Edit: Fixed indentation.
I suppose I could make my own add-on to SRL with that in… hmm…

Sandstorm

2009-01-22 19:42:47

One thing you need to do:

Check if your on the skill tab!

Can't see anything else straight off the bat.

~Sandstorm

marpis

2009-01-23 00:32:34

asdfLooks like nice functions! i might try those in my woodcutter maybe

Bad Processor

2009-01-23 12:25:59

Marpis,
Please give me some credit :O
And whats with the asdf at the beginning of your post? Lol.

And sandstorm, doesnt the GetSkill function go onto the skills tab anyway?

– BP