❔ Need some help fixing this simple if statement

I want the script to cache the previously grinded block and store it then echo the name of that block, every time I try to move the variables around I either get NULL or the currently grinded block, is anyone able to help me out here with fixing this code?
9 Replies
Buddy
Buddy2y ago
$paste
MODiX
MODiX2y ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
xxsupahbakedxx
xxsupahbakedxxOP2y ago
BlazeBin - sguulxwtoitd
A tool for sharing your source code with the world!
xxsupahbakedxx
xxsupahbakedxxOP2y ago
the variable I am having issues with is lastground
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
xxsupahbakedxx
xxsupahbakedxxOP2y ago
No this has not been solved
Noah
Noah2y ago
@Connolly assign the displayname variable to lastground after the successful grind. Then, Echo the lastground variable to display the name of the last ground block.
foreach (var entry in randomized)
{
var theblock = entry.FatBlock;
var blockname = "NULL";
var displayname = "NULL";

blockname = StatusAndLogDisplay.BlockName(entry);
try
{
// code to get the display name of the block
}
catch
{
}

if (blockname.Contains("Armory") || blockname.Contains("Proficient") || blockname.Contains("Enhanced") || blockname.Contains("Exotic") || blockname.Contains("Elite") || blockname.Contains("Nanovirus") || blockname.Contains("Lockers") || blockname.Contains("Freight"))
{
// Blocks to grind if GrindTech is on
if (GrindTech == "Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if (blockname.Contains("Beacon"))
{
// Blocks to be ground if GrindBeacon is on
if (GrindBeacon == "Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if ((blockname.Contains("Glowing") || blockname.Contains("Tritanium") || !blockname.Contains("Armor")))
{
// Blocks to be ground if GrindAll is on
if (GrindAll=="Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if ((blockname.Contains("AQD") || blockname.Contains("CubeBlock")))
{
// Blocks to be ignored if GrindAll is on
if (GrindAll=="Y")
{
continue;
}
}
}

_Program.Echo("");
_Program.Echo("Grind Ignored: " + count.ToString() + " Blocks");
_Program.Echo("");
_Program.Echo("Last Ground: " + lastground); // Echo the name of the last ground block
foreach (var entry in randomized)
{
var theblock = entry.FatBlock;
var blockname = "NULL";
var displayname = "NULL";

blockname = StatusAndLogDisplay.BlockName(entry);
try
{
// code to get the display name of the block
}
catch
{
}

if (blockname.Contains("Armory") || blockname.Contains("Proficient") || blockname.Contains("Enhanced") || blockname.Contains("Exotic") || blockname.Contains("Elite") || blockname.Contains("Nanovirus") || blockname.Contains("Lockers") || blockname.Contains("Freight"))
{
// Blocks to grind if GrindTech is on
if (GrindTech == "Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if (blockname.Contains("Beacon"))
{
// Blocks to be ground if GrindBeacon is on
if (GrindBeacon == "Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if ((blockname.Contains("Glowing") || blockname.Contains("Tritanium") || !blockname.Contains("Armor")))
{
// Blocks to be ground if GrindAll is on
if (GrindAll=="Y")
{
lastground = displayname; // Store the name of the block that was successfully ground
_Program.Echo("Grind: " + displayname);
groupData.RepairSystems.CurrentPickedGrindTarget = entry;
break;
}
}
else if ((blockname.Contains("AQD") || blockname.Contains("CubeBlock")))
{
// Blocks to be ignored if GrindAll is on
if (GrindAll=="Y")
{
continue;
}
}
}

_Program.Echo("");
_Program.Echo("Grind Ignored: " + count.ToString() + " Blocks");
_Program.Echo("");
_Program.Echo("Last Ground: " + lastground); // Echo the name of the last ground block
xxsupahbakedxx
xxsupahbakedxxOP2y ago
Thank you so much will test this out and let you know! Everything seems to be working now with this code however it shows the same block for the Last Ground as the what's being currently Grinded
xxsupahbakedxx
xxsupahbakedxxOP2y ago
BlazeBin - ttozzenvneon
A tool for sharing your source code with the world!
Want results from more Discord servers?
Add your server