SRL Archive - MSI Suggestions

SmartColors?


marpis

2009-11-22 09:22:01

Like many of us knows, RM just wrote very nice functions for SmartColors.SCAR, which has already been committed to open-dev repo.

Should we just use those functions as a base for all MS finding?
We would make an array of the TMSObj and record colors and stuff from all objects and NPCs we're using. The only object finding function would be


{*******************************************************************************
Function SmartColors(FindWhat: string): boolean;
By: Rasta Magician
Description: Finds object 'FindWhat'. Need to call MakeObj first.
*******************************************************************************}
Function SmartColors(FindWhat: string): boolean;

But we would first change the function a bit, so the parameter would be Integer instead of String, and the "FindWhat" parameter would be the index of Array og TMSObj. I also think the name of the function should be SmartFinder(FindWhat: Integer): Boolean;

Example:

Var
Objects: Array [0..3] Of TMSObj;

Const
NPC_GIANTRAT = 0;
NPC_SCORPION = 1;
OBJ_ROCK_IRON = 2;
OBJ_TREE_YEW = 3;

Procedure LoadColorInfo;
Begin
With Objects[NPC_GIANTRAT] Do
Begin
Name := 'iant';
Color := 123123;
Hue := 0.04;
Sat := 1.22;
...
End;
End;

{ Finding a Giant Rat }
SmartFind(NPC_GIANTRAT)
// or
SmartColor(NPC_GIANTRAT)
// depending on which is the final name of the function. I think SmartColors() can be misleading.

Instead of just updating the colours in the array, we should save all the changes in an .INI or something.

What do you guys think?

Sir R. M8gic1an

2009-11-22 09:28:49

They'd crash or you'd need a second copy of the include.

SmartColors already uses an array of TMSObj, declared in SmartColors.

What you could do is once the script is done running save it to an ini
and load it from an ini when it starts running.

Also,


const
ROCK_MITHRIL = 0;
ROCK_COAL = 1;
ROCK_TIN = 3;

function ConstToString(which: integer): string;
begin
case which of
ROCK_MITHRIL : Result := 'mith';
ROCK_COAL : Result := 'coal';
ROCK_TIN : Result := 'tin';
end;
end;

SmartColors(ConstToString(ROCK_MITHRIL));

// or just simply
SmartColor(IntToStr(ROCK_MITHRIL));


And don't forget you have to use MakeObj for it to be Added to the SmartColors recordfor it to be abe to work.

~RM

Sir R. M8gic1an

2009-11-22 12:30:07

Also, I do not mean to sound vain, but thanks to OrganizeColors very little changes are made to the array,i've been watching it run for a couple of hours and the maximum it did was reach color #3 no tol, meaning that after 2 hours only 4 colors slightly changed places, meaning that the inis aren't really needed.

With previous algorithms it'd take about 20 mins for SmartColors to have a good array of colors, but right now that isn't the case anymore.

~RM

marpis

2009-11-22 13:30:08

From: Rasta Magician
Also, I do not mean to sound vain, but thanks to OrganizeColors very little changes are made to the array,i've been watching it run for a couple of hours and the maximum it did was reach color #3 no tol, meaning that after 2 hours only 4 colors slightly changed places, meaning that the inis aren't really needed.

With previous algorithms it'd take about 20 mins for SmartColors to have a good array of colors, but right now that isn't the case anymore.

~RM


I meant like, read once on startup and write on scriptterminate, that wouldn't crash/mess anything. The nice thing about this would be that even if Jagex changed a few colours every now and then, the script wouldn't need to be updated.

Sir R. M8gic1an

2009-11-22 13:55:55

SmartColors now takes a variant as identifier meaning we can do

SmartColors(ROCK_MITHRIL); without any trouble whatsoever.

~RM

Coh3n

2009-11-23 10:47:13

What you have in your example would go in ItemInfo.scar. Is this something like what you were thinking?
function MSI_FindObject(Obj: TMSObj): Boolean;
I, H: Integer;
begin
H := High(Obj.Colors)
for I := 0 to H do
begin
MakeObj(Obj.Name, Obj.Color[I], Obj.Tol, Obj.Hue, Obj.Sat, Obj.UpText, Obj.Options); // We would have to add Option to the TMSObj record.
SetupSmartColorsDetails( { if we wanted to go with the advanced method } );

Result := SmartColors(Obj.Name);

if Result then
Break;
end;
end;

Blumblebee

2009-11-25 19:52:41

I dont think we should use SmartColors, not enough flexability to do anything, as it does everything. I think we should have a function that results in a TPointArray, allowing the scripter to manipulate the TPA and do more with it. example:

Function GatherPoints(x, y, color, width, height, tolerance: Integer): TpointArray;
var TPA: TpointArray; ATPA: T2DpointArray; l, i, p: Integer;
begin
FindColorsSpiralTolerance(x, y, TPA, color, MSx1, MSy1, MSx2, MSy2, tolerance);
ATPA := TPAtoATPAEx(TPA, width, height);
for i := 0 to High(ATPA) do
begin
if Length(ATPA) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTPA(ATPA[i]);
end;
end;
end;

allows the scripter to then further manipulate the tpa via SortTPASize() TPAtoATPA, SplitTPA, SortATPASize, InvertTPA, etc. Gives the scripter more freedom with object finding, and gives them something to do aside from just simple going SmartColors() then FindObject('rock');

I just think we don't need to spoon feed people everything for MSI. anyways, just my thoughts.

Coh3n

2009-11-25 20:33:42

From: Blumblebee
I dont think we should use SmartColors, not enough flexability to do anything, as it does everything. I think we should have a function that results in a TPointArray, allowing the scripter to manipulate the TPA and do more with it. example:

allows the scripter to then further manipulate the tpa via SortTPASize() TPAtoATPA, SplitTPA, SortATPASize, InvertTPA, etc. Gives the scripter more freedom with object finding, and gives them something to do aside from just simple going SmartColors() then FindObject('rock');

I just think we don't need to spoon feed people everything for MSI. anyways, just my thoughts.


I agree with your thinking. To be quite honest, if I was asked if I thought SmartColors should be added to SRL, I don't know what I would have said. You're right, it does all the work for you. However, it is probably one of the best object finding methods we have at our disposal.

It's a tough decision because I, too, don't want to spoon feed people, as it doesn't teach anything, but it's hard to have something like SmartColors, and not use it. Know what I mean?

I'd like to see what other people think about this.

NCDS

2009-11-26 00:15:31

I've already discussed with this Blumblebee and I agree with him as well that SmartColors is almost too simple.At the same time though, there is going to be a lot of people helping with this project and a function as basic, yet effective as this would help with keeping things organized.

I will work with whichever way is chosen by the majority.

Do you think maybe an SRL Members poll may be something to consider? Since they are going to be the ones using these functions (hopefully).

Coh3n

2009-11-26 11:10:37

From: NCDS
Do you think maybe an SRL Members poll may be something to consider? Since they are going to be the ones using these functions (hopefully).

That's not a bad idea, it may be helpful to see what everyone else thinks.