PDA

View Full Version : Need assistance in getting a result?



Clutch
07-16-2015, 06:28 AM
I am trying to get LOG_TYPE = % for my progress report.
I have declared it as a global variable as an intenger as seen below.
In Procedure UseMill() I have multiple if else statements which will detect the different types of logs - and for each type of log it will produce a different %.
The issue is the % isn't carrying over from this procedure to my progress report and I can't seem to figure out a good way of doing this.

1. What's a good way to handle getting ID's to a Variable to a result?
2. UseMill(); Could/should I make this into a case statement opposed to multiple else...ifs?
3. Any other suggestions on cleaning up the script/improvements? (no not the full script just the only sections related to this problem)

var
nextRotateCamera, nextReaction, canPaint: tCountDown;
presetString: string;
Logs, rightClick, scriptPaintBMP, LOG_TYPE: integer;
didClickWell: boolean;
clientCenter: TPoint;
{PROCEDURE -- useMill
Purpose: Uses the nearest portable well.
Comments: None.}
procedure useMill;
var
modelsMill: glModelArray;
millTPA: TPointArray;
begin
if inventory.getItems(116280, 3089172) then
LOG_TYPE=0.04
else if inventory.getItems(116280, 4075035) then
LOG_TYPE=0.06
else if inventory.getItems(116280, 5391405) then
LOG_TYPE=0.08
else if inventory.getItems(116280, 4733476) then
LOG_TYPE=0.10;
ClutchDebug('Clicking on the portable mill.');
if dialogue.hasDialogue() then
typeByte(VK_ESCAPE);
if (modelsMill := ogl.getModels(1573756966)).indexes then
begin
millTPA := ogl.getClientMidPoint().closest(modelsMill);
if (random(rightClick) = 0) then
mouse.rightClickOption(millTPA[0].adjustPosition(0, -10).randomizePointEllipse(30), ['Make Planks Portable mill'])
else
mouse.click(millTPA[0].adjustPosition(0, -10).randomizePointEllipse(30));
end;
nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
end;

{PROCEDURE -- progressReport
Purpose: Calculates and paints progress on the screen.
Comments: None.}
procedure progressReport();
var
LogsUsed, LogsUsedPerHour, Protean, ProteanPerHour: extended;
LogsUsedString, LogsUsedPerHourString, ProteanString: string;
begin
LogsUsed := (Logs) * 28;
LogsUsedPerHour := Round(LogsUsed * (3600.0 / (GetTimeRunning / 1000.0)));
LogsUsedString := format('%n', [LogsUsed]);
LogsUsedPerHourString := format('%n', [LogsUsedPerHour]);
Protean := Round(LogsUsed * LOG_TYPE);
ProteanString := format('%n', [Protean]);
setLength(LogsUsedString, length(LogsUsedString) - 3);
setLength(LogsUsedPerHourString, length(LogsUsedPerHourString) - 3);
setLength(ProteanString, length(ProteanString) - 3);
if SHOW_PAINT and canPaint.isFinished() then
begin
smart.__Graphics.Clear;
smart.__graphics.drawBitmap(scriptPaintBMP, Point(0, 461)); //permission to restart script? go ahead as you can see this is heavily modified claritywells
smart.__graphics.drawText(ToStr(TimeRunning), 'smallChars', Point(127, 517), 1);
smart.__graphics.drawText(ToStr(TimeRunning), 'smallChars', Point(126, 516), clWhite);
smart.__graphics.drawText(LogsUsedString, 'smallChars', Point(114, 538), 1);
smart.__graphics.drawText(LogsUsedString, 'smallChars', Point(113, 537), clWhite);
smart.__graphics.drawText(LogsUsedPerHourString,'s mallChars', Point(114, 560), 1);
smart.__graphics.drawText(LogsUsedPerHourString,'s mallChars', Point(113, 559), clWhite);
smart.__graphics.drawText(ProteanString, 'smallChars', Point (101,590), 1);
smart.__graphics.drawText(ProteanString, 'smallChars', Point (100,589), clWhite);
canPaint.setTime(10000);
end;
end;

Clarity
07-16-2015, 06:32 AM
When assigning a variable a value, you need to use ":=", not just "=".


LOG_TYPE = 0.04; //wrong

LOG_TYPE := 0.04; //right


That should cause something to actually happen :)
Additionally, LOG_TYPE should be an extended variable (not an integer) if you are assigning it decimal values.


var
LOG_TYPE: extended;

Clutch
07-16-2015, 02:15 PM
That helped - the paint is now showing but still getting 0. Gonna test it out after work and hopefully have it up and running.