Log in

View Full Version : Profit.



Failure
11-26-2011, 01:34 PM
Been making a simple crafter for something, though I wanna know how much Profit I make. Everytime it goes through the Script it makes 185.832 GP.

How do I make it, everytime it goes through the Script till the end make it say

WriteLn('We have made [TotalAmount] profit'); so it will add +185.382 Gp each time. Thanks in advanced.

Awkwardsaw
11-26-2011, 01:36 PM
writeln('we made: ' + tostr(floor(TotalAmount)) + ' profit');

floor() rounds down the number to an integer, tostr() converts the integer to string

Failure
11-26-2011, 01:43 PM
writeln('we made: ' + tostr(floor(TotalAmount)) + ' profit');

floor() rounds down the number to an integer, tostr() converts the integer to string

I don't really get it, I have this



var Profit:Integer;

Profit := 185382;

Inc(Profit);
Writeln('We have made ' + ToStr(Floor(Profit)) + ' profit.');

And it only adds +1, quite sure I'm doing something wrong?

Awkwardsaw
11-26-2011, 01:46 PM
inc() increases integers by one, if you want to add more than do


var
profit, totalprofit : integer;

begin
profit := 1337;//total profit per trip, or what ever
totalprofit := totalprofit + profit; //adds profit to what ever totalprofit is


Writeln('We have made ' + ToStr(Floor(totalProfit)) + ' profit.');
end.

e: fixed typos. ;)

i luffs yeww
11-26-2011, 01:48 PM
Inc(var) increments 'var' by one. IncEx(var, x) increments 'var' by x.

YoHoJo
11-26-2011, 01:49 PM
E: EDIT LOL OPPS. Thought you wanted profit/hour, not just profit... oh well...

Here is a progress report for one of my scripts
Procedure ProgressReport;
Var
StoneRate: Integer;
Begin
SRLRandomsReport;
//Stats_Commit;
Sec:= (1+((Getsystemtime-StartTime)/1000));
StoneRate:=(3600*(TStones))/(Sec);
Writeln(' ');
Writeln('');
Writeln ('/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\');
Writeln ('| --> YUGAY '+Version+ + PadL('<-- |', 15) );
Writeln ('\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/');
Writeln('|' + PadR( (' Worked for '+ TimeRunning) , 39) + '|');
Writeln('|' + PadR( (' Created '+IntToStr(TStones) +' Gatstones'), 39) + '|');
Writeln('|' + PadR( (' Gained '+FloatToStr(TStones * 43.5) +' Experience'), 39) + '|');
Writeln('|' + PadR( (' Created ' + IntToStr(StoneRate) + ' Stones/Hour'), 39) + '|');
Writeln('|' + PadR( (' Gained '+GroupDigits(Round(XPRate), ',') +' Experience/Hour'), 39) + '|');
Writeln ('\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/');
Writeln('');
End;

So lets say your script alches (example).
After each alch put something like
Profit:= Profit+28;
(Assuming you make 28 profit per alch)

In the very start of your script (like after SetupSRL or Login), put
StartTime:= GetSystemTime;
(And declare StarTime as in integer at the top of your script).

Then have
Sec:= (1+((Getsystemtime-StartTime)/1000));
ProfitHR:=(3600*(Profit))/(Sec);

And also declare ProfitHR and Profit as integers at the top of your script.

So then doing
Writeln('Gained '+GroupDigits(Round(ProfitHR), ',') +' Profit/Hour');

Will spit out your profit/hr.

Failure
11-26-2011, 02:01 PM
inc() increases integers by one, if you want to add more than do


var
profit, totalprofit : integer;

begin
profit := 1337;//total profit per trip, or what ever
totalprofit := totalprofit + profit; //adds profit to what ever totalprofit is


Writeln('We have made ' + ToStr(Floor(totalProfit)) + ' profit.');
end.

e: fixed typos. ;)

Tried, but ehh seems to keep giving me the same amount of profit.


E: EDIT LOL OPPS. Thought you wanted profit/hour, not just profit... oh well...

Here is a progress report for one of my scripts
Procedure ProgressReport;
Var
StoneRate: Integer;
Begin
SRLRandomsReport;
//Stats_Commit;
Sec:= (1+((Getsystemtime-StartTime)/1000));
StoneRate:=(3600*(TStones))/(Sec);
Writeln(' ');
Writeln('');
Writeln ('/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\');
Writeln ('| --> YUGAY '+Version+ + PadL('<-- |', 15) );
Writeln ('\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/');
Writeln('|' + PadR( (' Worked for '+ TimeRunning) , 39) + '|');
Writeln('|' + PadR( (' Created '+IntToStr(TStones) +' Gatstones'), 39) + '|');
Writeln('|' + PadR( (' Gained '+FloatToStr(TStones * 43.5) +' Experience'), 39) + '|');
Writeln('|' + PadR( (' Created ' + IntToStr(StoneRate) + ' Stones/Hour'), 39) + '|');
Writeln('|' + PadR( (' Gained '+GroupDigits(Round(XPRate), ',') +' Experience/Hour'), 39) + '|');
Writeln ('\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/');
Writeln('');
End;

So lets say your script alches (example).
After each alch put something like
Profit:= Profit+28;
(Assuming you make 28 profit per alch)

In the very start of your script (like after SetupSRL or Login), put
StartTime:= GetSystemTime;
(And declare StarTime as in integer at the top of your script).

Then have
Sec:= (1+((Getsystemtime-StartTime)/1000));
ProfitHR:=(3600*(Profit))/(Sec);

And also declare ProfitHR and Profit as integers at the top of your script.

So then doing
Writeln('Gained '+GroupDigits(Round(ProfitHR), ',') +' Profit/Hour');

Will spit out your profit/hr.

Thanks for your help, but to complicated lol. :duh:

YoHoJo
11-26-2011, 02:06 PM
Inc only incrases by 1.
Like I luffs yew said, use IncEx.

it would be like

IncEx(Profit, 20); (assuming you make 20 profit each time, you can change to what you want)

Failure
11-26-2011, 02:10 PM
Inc only incrases by 1.
Like I luffs yew said, use IncEx.

it would be like

IncEx(Profit, 20); (assuming you make 20 profit each time, you can change to what you want)

Well I never used those things, thanks for your example it worked!
Also thanks to you Like I Luffs, it worked :D

Zyt3x
11-26-2011, 02:30 PM
Inc(l) is faster than l := l + 1;
but
IncEx(l, e) is slower than l := l + e;

just a heads-up for those who are thinking about speed

Camaro'
11-26-2011, 04:47 PM
Inc(l) is faster than l := l + 1;
but
IncEx(l, e) is slower than l := l + e;

just a heads-up for those who are thinking about speed

How much faster could it be?

Wyn
11-26-2011, 06:55 PM
How much faster could it be?

10ms? lol

marpis
11-26-2011, 07:16 PM
Inc(l) is faster than l := l + 1;
but
IncEx(l, e) is slower than l := l + e;

just a heads-up for those who are thinking about speed

Well, not relevant when we are thinking about progressreports :p
Maybe when making a plugin that uses Inc() hundreds of times per second.

i luffs yeww
11-26-2011, 08:21 PM
Inc(l) is faster than l := l + 1;
but
IncEx(l, e) is slower than l := l + e;

just a heads-up for those who are thinking about speed

I have a thread somewhere about this. In SCAR this was the case. However, in Simba, it's not the same. I don't recall what the case is, though. I should look for wherever that information is.

But to OP, using IncEx or i := i + x really doesn't matter. For one, you'd call it relatively rarely, so the few nanosecond (definitely not a 10ms difference.. :p that's quite a bit) difference every few minutes or whatever doesn't matter, really.

TomTuff
11-26-2011, 08:39 PM
I was bored :p

program Test;

var
T1, T2, i, x, C: Integer;

begin
ClearDebug;
repeat
T1 := GetSystemTime;
for i := 1 to 1000000 do
IncEx(x, 11);
writeln(GetSystemTime-T1);
T2 := GetSystemTime;
for i := 1 to 1000000 do
x := x + 11;
writeln(GetSystemTime-T2);
writeln('');
inc(C);
until (C = 50)
end.



Results:

First number is IncEx, Second is x := x + y.

3448
1825

3276
1763

3214
1762

3214
1762

3230
1762

3214
1762

3214
1763

3198
1762

3230
1763

3214
1763

3198
1763

3214
1778

3214
1762

3230
1778

3214
1763

3213
1763

3213
1747

3214
1762

3214
1778

3229
1763

3198
1778

3214
1763

3276
1763

3213
1779

3229
1747

3229
1763

3214
1763

3214
1762

3214
1762

3214
1763

3198
1763

3230
1763

3354
1856

3292
1794

3479
1763

3198
1747

3213
1763

3213
1748

3323
1919

3494
2060

3370
1841

3339
2200

3619
1981

3432
1919

3573
1888

3323
1981

3401
1779

3307
1841

3307
1809

3416
1762

i luffs yeww
11-26-2011, 08:48 PM
Well regardless, the difference is between 3.3 µs (microseconds) and 1.7 µs (microseconds). So nothing. :p