We all know that the Gold Digging command doesn't work. I dunno if anyone has done this yet or not with Lua, but I created an Actor that will search for and mine for gold on its own, using goto waypoints. Here's some gifs of it:
Be sure to watch the yellow waypoint marker on this one. Keep in mind, I'm actually in control of the brain robot, not the dummy that's digging.
Here's the code I used (can cause some lag):
Code:
function Create(self)
self.bSearch = false; --Is the AI searching for a gold spot?
self.bLookForGold = false; --Should the AI look for a gold spot?
--self.crouchTimer starts at nil, and becomes a timer when Down is held.
--Once the timer passes self.holdTime, then the timer becomes false.
--When Down is released, the timer goes back to nil.
self.crouchTimer = nil;
self.holdTime = 1500;
self.searchWidth = 250;
self.searchHeight = 250;
self.deltay = 0;
self.searchAcc = 2;
self.LockPos = nil;
end
function Update(self)
local controller = self:GetController();
if controller:IsPlayerControlled(-1) then
if controller:IsState(Controller.BODY_CROUCH) then
if self.crouchTimer == nil then
self.crouchTimer = Timer();
elseif self.crouchTimer ~= false then
if self.crouchTimer:IsPastSimMS(self.holdTime) then
self.bLookForGold = not self.bLookForGold;
self.bSearch = self.bLookForGold;
self.deltay = 0;
self.LockPos = nil;
self.crouchTimer = false; --Taking advantage of dynamic type >:)
self:FlashWhite(100);
end
end
elseif self.crouchTimer ~= nil then
self.crouchTimer = nil;
end
else --AI is running the show.
if self.bLookForGold then
if self:GetLastAIWaypoint() == self.Pos then
self.bSearch = true;
end
if self.bSearch then
if self.LockPos == nil then
self.LockPos = self.Pos;
end
local div = self.searchWidth/2;
if self.deltay <= self.searchHeight then
for i = -div, div, self.searchAcc do
local poi = self.LockPos + Vector(i,self.deltay);
print(SceneMan:GetTerrMatter(poi.X,poi.Y));
if SceneMan:GetTerrMatter(poi.X,poi.Y) == 2 then --GOLD!
print(poi);
self.AIMode = Actor.AIMODE_GOTO;
self:AddAISceneWaypoint(poi);
self:DrawWaypoints(true);
self.bSearch = false;
break;
end
end
self.deltay = self.deltay + 1;
else
self.bSearch = false;
end
end
end
end
end