Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Getting data from another file

Ask for help
Post Reply
DeadLy_DeMaGe
Neophyte
Neophyte
Posts: 17
Joined: 10.01.2015 3:01

Getting data from another file

Post by DeadLy_DeMaGe »

I am working on some mining script that recalls and gathers ore. I studied most of the mining scripts in Russian section but none of them uses dig locations. To be more clear, what I mean is giving every single dig location data (Tile, X, Y, Z) for each rune spot to script. I am planning saving this data in another file (DigLocation1.txt for example) rather then inside the main script. In Felix's script, finding dig spots used like this;

Code: Select all

procedure MinePoint; //New
var
  X, Y: Word;
begin
  X := GetX(Self);
  Y := GetY(Self);
  Mine(X, Y);
  Mine(X + 1, Y);
  Mine(X + 1, Y + 1);
  Mine(X, Y + 1);
  Mine(X - 1, Y + 1);
  Mine(X - 1, Y);
  Mine(X - 1, Y - 1);
  Mine(X, Y - 1);
  Mine(X + 1, Y - 1);
  Mine(X + 2, Y + 2);
  Mine(X - 2, Y + 2);
  Mine(X - 2, Y - 2);
  Mine(X + 2, Y - 2);
end;
And this is what I planned to do;

Code: Select all

procedure MinePoint; //New
var
  Tile, X, Y, Z: SmallInt;
begin
  Tile := 0;
  X := 1;
  Y := 2;
  Z := 3;
  Mine(Tile, X, Y, Z);
end;
This is the simple use ofcourse. What you think? What should I do for using script like that.
DeadLy_DeMaGe
Neophyte
Neophyte
Posts: 17
Joined: 10.01.2015 3:01

Re: Getting data from another file

Post by DeadLy_DeMaGe »

Well, I searched for a while and figured out how to load other files (like .txt's) to script thanks to FreD's Fishing thread. This is the sample usage;

Code: Select all

Program Mining;
type DigPoint = record
   tile:word;
   px,py,pz:integer;
   
end;

var
   ItemCount,i:Integer;
   DigLoc: array [0..150] of DigPoint;
   
Procedure GetDigLocations(s:String;WPos:Integer);
begin
   s := s + ' '; 
   DigLoc[WPos].tile:=StrToInt(Copy(s,1,Pos(' ',s)-1));
   Delete(s,1,Pos(' ',s));
   DigLoc[WPos].px:=StrToInt(Copy(s,1,Pos(' ',s)-1));
   Delete(s,1,Pos(' ',s));
   DigLoc[WPos].py:=StrToInt(Copy(s,1,Pos(' ',s)-1));
   Delete(s,1,Pos(' ',s));
   DigLoc[WPos].pz:=StrToInt(Copy(s,1,Pos(' ',s)-1));
   Delete(s,1,Pos(' ',s));
end;

var
   List:TStringList;
begin
   List:=TStringList.Create;
   List.LoadFromFile('DigLocations.txt');
   for i := 0 to List.Count-1 do
      GetDigLocations(List.strings[i],i);
   ItemCount:=i;
end.
It obtains x, y ,z and tile information from DigLocations.txt. The problem I couldnt figured out is how do I make script obtain only current rune's dig data? Lets say I have a Rune Book which has 16 runes in it and lets say every rune in this book has 3 different dig locations. That makes 48 different dig locations but script only need dig locations of current rune. How do I make this exception? For making script only looks for current runes dig locations?
Post Reply