In other cases, where the update-able numbers/strings only effect one function, should they be local or global? For example, for InvBox to calculate the clickable areas correctly, you need the X1, Y1, X2, Y2 of the first slot in the first row, and the X1, Y1 of the second slot in the second row. Rather than having 6 variables Inv_Box_X1, Inv_Box_Y1....etc, I clumped them all together into a couple of TBoxes. I'm thinking keep local for this case, as I don't see why a scripter would need to use those values, plus if they really wanted them they could generate them by using InvBox itself.
SCAR Code:
{*******************************************************************************
Function InvBox(i :Integer): TBox;
By: Boreas. Coords by Ogre July 15th 2009.
Description: Returns TBox of surrounding Inventory SlotBox
1-2-3-4
5-6-7-8
etc.
*******************************************************************************}
function InvBox(i :Integer): TBox;
var Slot1, Slot6: TBox;
begin
if not InRange(I, 1, 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
Slot1 := IntToBox(563,213,594,244); //update these
Slot6 := IntToBox(605,249,31415,92653); //except pi :p
Result.x1 :=Slot1.X1+((((i+(4-1))mod 4))*(Slot6.X1-Slot1.X1)); //4 for number
Result.y1 :=Slot1.Y1+((((i-1)/4))*(Slot6.Y1-Slot1.Y1)); //of columns
Result.x2 := Result.x1+(Slot1.X2-Slot1.X1);
Result.y2 := Result.y1+(Slot1.Y2-Slot1.Y1);
end;
//when i click i dont just click within the black outline
procedure MMouseItem(i: Integer);
var
TB: TBox;
begin
GameTab(tab_inv);
TB:=InvBox(I);
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2,3);
end;
That was in the OpenDev SVN the other day, but now somebody has replaced it with the old one...