YoHoJo
2012-01-07 00:03:35
Function MineRock(WutRock:Integer):Boolean; Got that.
Want it to return the Boolean like it already does, AND an Integer (planning to make it how many rocks with ores it found).
How Do?
2012-01-07 00:03:35
Function MineRock(WutRock:Integer):Boolean; 2012-01-07 00:10:57
2012-01-07 00:12:02
2012-01-07 00:12:22
program new;
type
Custom = record
Bool: boolean;
Int: Integer;
end;
Function LetsReturnTwoValues: Custom;
begin
//Do stuff to get some results/values..
//.................
//.................
//Return two values..
Result.Bool:= True;
Result.Int:= 5035
end;
Procedure AssignTwoValues;
var
TwoVals: Custom; //Notice the Custom type..
begin
//This will Access/Assign the two values.. NOT return..
writeln(TwoVals.Bool);//Accessing
TwoVals.Bool:= False; //Assigning
TwoVals.Int:= 5252352;
end;
2012-01-07 00:15:18
2012-01-07 00:17:48
//That function above.. has now stored it's results in Bool and Int of the Custom Record right?
//Now lets access those values so we can do stuff with them..
var
Rock: Custom;
begin
writeln(Rock.Bool); //Accessing the values of Rock which is of type custom.. should print true..
Writeln(Rock.Int); //This should print that 5035..
end.
2012-01-07 00:21:13
var
ret : Integer;
if(MineRock(ROCK_IRON, ret))then
WriteLn(IntToStr(ret));
type
Custom = record
Bool : Boolean;
Int : Integer;
end;
function retValues() : Custom;
begin
with Result do
begin
Bool := True;
Int := 123;
end;
end;
procedure printValues();
var
ret : Custom;
begin
ret := retValues();
WriteLn(BoolToStr(ret.Bool));
WriteLn(IntToStr(ret.Int));
end;
2012-01-07 00:22:37
If MineRock(Players[CurrentPlayer].Integers[1]).Bool=True Then
2012-01-07 00:31:45
2012-01-07 00:37:36
If MineRock('Iron') Then
Begin
AntiBan;
Sex;
End;If MineRock<5 Then
MoveToAnotherLocation;
2012-01-07 00:40:56
var
NumFound: Integer;
If MineRock('Iron', NumFound) Then
Begin
AntiBan;
Sex;
End;
2012-01-07 00:42:47
type
TRock = record
Found : Boolean;
HowMany : Integer;
end;
function MineRock(Which : Integer) : TRock;
begin
// Do mining stoof
with Result do
begin
Found := True; // Could be used in a TPA and set True/False depending if it was found
HowMany := 3; // Same idea with TPA, Length(TPA)
end;
end;
procedure MainLoop;
var
pRock : TRock;
begin
pRock := MineRock(ROCK_IRON);
if(pRock.HowMany < 5)then
MoveToAnotherLocation;
end;
2012-01-07 01:19:54
2012-01-07 06:22:47
From: YoHoJo
How do I do something likeIf MineRock(Players[CurrentPlayer].Integers[1]).Bool=True Then
result:= MineRock(Players[CurrentPlayer].Integers[1])
if result.bool = true then
;//do whatever you want?
2012-01-07 07:17:41
program new;
function returnTwoVals(val1: integer; val2: boolean): tVariantArray;
begin
Result := [val1, val2];
end;
var
tva: tVariantArray;
begin
tva := returnTwoVals(5,true);
writeLN(intToStr(tva[0]) + ', ' + boolToStr(tva[1]));
end.
2012-01-07 07:40:23
2012-01-07 08:46:05
if MineRock(rock, number) then
Writeln('Found '+toStr(number));
2012-01-07 08:58:07
From: NCDS
Why is this being so over complicated?
function MineRock(Rock: Integer; var numRock: Integer): Boolean;
When you put 'var' in front of a parameter you can use that variable inside the function and ooutside.
So, with the example I just used:
if MineRock(rock, number) then
Writeln('Found '+toStr(number));
2012-01-10 03:05:56
If MineRock.Boolean Then blalbalbalANDWriteLn(IntToStr(MineRock.Integer)));if MineRock(rock, number) then
Writeln('Found '+toStr(number));FindColorsSpiralTolerance(MSCX,MSCY,OrePts,2434854,SearchBox.x1,SearchBox.y1,SearchBox.x2,SearchBox.y2,10); 2012-01-10 04:03:57
program new;
type
MineRockInfo = record
Boolean: Boolean;//Might want to change the variable name 'Boolean' to something like 'found'
Integer: Integer;//Might want to change the variable name 'Integer' to something like 'amount'
end;
function MineRock: MineRockInfo;
begin
Result.Boolean := True;
Result.Integer := 5;
end;
begin
Writeln(BoolToStr(MineRock.Boolean));
Writeln(IntToStr(MineRock.Integer));
end.
That would however call the function twice that we don't want.
program new;
type
MineRockInfo = record
Boolean: Boolean;//Might want to change the variable name 'Boolean' to something like 'found'
Integer: Integer;//Might want to change the variable name 'Integer' to something like 'amount'
end;
var
MineInfo: MineRockInfo;
function MineRock: MineRockInfo;
begin
Result.Boolean := True;
Result.Integer := 5;
end;
begin
MineInfo := MineRock;//MineRock only being called once!
Writeln(BoolToStr(MineInfo.Boolean));
Writeln(IntToStr(MineInfo.Integer));
end.
2012-01-10 04:07:45
2012-01-10 04:09:42
From: YoHoJo
I'm still lost here, :/.
I have the function MineRock(WutRock:Integer); (Wutrock (1, 2, 3, etc etc) just means iron, coal, tin, etc.
I want to be able to do something likeANDIf MineRock.Boolean Then blalbalbalWriteLn(IntToStr(MineRock.Integer)));
With the same function.
So, RM and NCDS are sayingif MineRock(rock, number) then
Writeln('Found '+toStr(number));
So um, how would I assign a value to 'number'?
Like let's say I gotFindColorsSpiralTolerance(MSCX,MSCY,OrePts,2434854,SearchBox.x1,SearchBox.y1,SearchBox.x2,SearchBox.y2,10);
How would I make the number of rocks found, in our case here 'number' := OrePts (OrePts right now ofc is an TPA).
Function MineRock(WutRock:Integer; out NumOfRocks):Boolean;
if MineRock(Rock, Number) then
NumOfRocks := Length(OrePts);