Simba Code: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?
Simba Code: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?
Function MineRock(WutRock:Integer, var ProducedInt: Integer):Boolean;
?
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
Um, so then how would I call/use that elsewhere to find out how many?
Like Writeln(IntToStr(WHAT?!));
How do? What u mean?
Like this?
Simba Code: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;
I am Ggzz..
Hackintosher
I don't get the AssignTwoValues :/
Everything above that seems to be what I want though hmmm
It's just a function I made to I guess show you how to access the values you have stored..
Simba Code://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.
I am Ggzz..
Hackintosher
Based on what you want:
Simba Code:var
ret : Integer;
if(MineRock(ROCK_IRON, ret))then
WriteLn(IntToStr(ret));
However, I'd suggest a Type like ggzz posted.
Simba Code: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;
Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
{ MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }
When posting a bug, please post debug! Help us, help you!
I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.
SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.
How do I do something like
Simba Code:If MineRock(Players[CurrentPlayer].Integers[1]).Bool=True Then
Last edited by YoHoJo; 01-07-2012 at 05:26 AM.
I'm confused on what you want to accomplish...?
Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
{ MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }
When posting a bug, please post debug! Help us, help you!
I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.
SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.
I want the function to return TRUE if rock was found/clicked AND I want it to return how many rocks were found.
Like I want to use it like
Simba Code:If MineRock('Iron') Then
Begin
AntiBan;
Sex;
End;
And elsewhere in the script I want to do
Simba Code:If MineRock<5 Then
MoveToAnotherLocation;
Something like this?
Simba Code:var
NumFound: Integer;
If MineRock('Iron', NumFound) Then
Begin
AntiBan;
Sex;
End;
An use the NumFound elsewhere? If it's used in multiple places it'll have to be a global variable. I dunno though, I might still be off track as to your request.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
Simba Code: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;
Something like that?
Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
{ MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }
When posting a bug, please post debug! Help us, help you!
I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.
SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.
Instead of creating a whole new type, surely you could just create a tVariantArray. Would save the messing about with with..dos and all that. Wouldn't really be that complex:
Simba Code: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.
Last edited by Richard; 01-07-2012 at 12:44 PM.
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:
Simba Code:if MineRock(rock, number) then
Writeln('Found '+toStr(number));
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 like
ANDSimba Code:If MineRock.Boolean Then blalbalbal
Simba Code:WriteLn(IntToStr(MineRock.Integer)));
With the same function.
So, RM and NCDS are saying
Simba Code:if MineRock(rock, number) then
Writeln('Found '+toStr(number));
So um, how would I assign a value to 'number'?
Like let's say I got
Simba Code:FindColorsSpiralTolerance(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).
Like this?
That would however call the function twice that we don't want.Simba Code: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.
Here is a better example:
Simba Code: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.
Thanks for clarification I also talked to Kyle and I think I've gotten it figured out thanks everyone. Plan to release another script in the next few weeks.
Going to be called Dr. Dick.
When you place 'var' in front of a parameter, you are letting the function/procedure know that not only are you passing a variable in, but that you are wanting the function/procedure to pass information out through the variable. If you put 'out' in front of a parameter, the function/procedure will ignore the current value of the variable, and will only pass out the modified version of it. So, if we do something like:
Simba Code:Function MineRock(WutRock:Integer; out NumOfRocks):Boolean;
and you then do:
Simba Code:if MineRock(Rock, Number) then
And somewhere in the function you put:
Simba Code:NumOfRocks := Length(OrePts);
Then after the function is through, you'll have the number of returned points stored within 'Number'. If you want to do further stuffz in the function to return just the rocks, you need to remember to set 'NumOfRocks' to that final value.
Last edited by euphemism; 01-10-2012 at 05:01 PM.
[10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts
There are currently 1 users browsing this thread. (0 members and 1 guests)