Data Realms Fan Forums
http://45.55.195.193/

I'm having trouble with a script, help please
http://45.55.195.193/viewtopic.php?f=73&t=15793
Page 1 of 1

Author:  Foogooman [ Fri Jul 10, 2009 7:20 pm ]
Post subject:  I'm having trouble with a script, help please

Hello everyone. I have been playing with the map C-Storm and I have run into a bit of a problem. Someone requested I make the storm contain small particles that match the terrain, so that it is more realistic and more like a sandstorm. I've done that, but there's a problem. The storm doesn't last nearly long enough. The storm doesn't provide the desired effect in such a short time because they are just single pixels instead of entire crabs like the vanilla version of this map. I have tried to edit all sorts of variables, yet none of them seem to work. Here is the code, could you help me find which variable alters how long the storm lasts? I've tested nearly all of them, so maybe there isn't a time variable... If there isn't could someone add one?

Code:
-----------------------------------------------------------------------------------------
-- Start Activity
-----------------------------------------------------------------------------------------

function Storm:StartActivity()
   print("START! -- Storm:StartActivity()!");
   StormTimer = Timer();
   STime = math.random(30000) + 45000;
   ActivityMan.ActivityState = Activity.EDITING;
   intensity = 1;

    for player = 0, self.PlayerCount - 1 do
        -- Check if we already have a brain assigned
        if not self:GetPlayerBrain(player) then
                self.ActivityState = Activity.EDITING;
                    playerActor = CreateAHuman("Ronin Soldier");
                   playerActor.Pos = Vector(600,450);
                   playerActor.Team = 0;
                   playerActor:AddInventoryItem(CreateHDFirearm("Medium Digger"));
                   MovableMan:AddActor(playerActor);
                   self:SetPlayerBrain(playerActor, 0);
                   self:SetLandingZone(playerActor.Pos, 0);
                   self:SwitchToActor(playerActor, 0, self:GetTeamOfPlayer(0));
            local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(player));
            -- If we can't find an unassigned brain in the scene to give each player, then force to go into editing mode to place one
            if not foundBrain then
                playerActor = CreateAHuman("Ronin Soldier");
               playerActor.Pos = Vector(600,450);
               playerActor.Team = 0;
               playerActor:AddInventoryItem(CreateHDFirearm("Medium Digger"));
               MovableMan:AddActor(playerActor);
               self:SetPlayerBrain(playerActor, 0);
               self:SetLandingZone(playerActor.Pos, 0);
               self:SwitchToActor(playerActor, 0, self:GetTeamOfPlayer(0));
            else
                -- Set the found brain to be the selected actor at start
                self:SetPlayerBrain(foundBrain, player);
                self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player));
                self:SetLandingZone(self:GetPlayerBrain(player).Pos, player);
                -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observation mode
                self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player);
            end
        end
    end
end

-----------------------------------------------------------------------------------------
-- Pause Activity
-----------------------------------------------------------------------------------------

function Storm:PauseActivity(pause)
   print("PAUSE! -- Storm:PauseActivity()!");
end

-----------------------------------------------------------------------------------------
-- End Activity
-----------------------------------------------------------------------------------------

function Storm:EndActivity()
   print("END! -- Storm:EndActivity()!");
end

----------------------------------------------------------------------------------------------------------
-- Update Activity
----------------------------------------------------------------------------------------------------------

function Storm:UpdateActivity()
   if StormTimer:LeftTillSimMS(STime) < 10000 and StormTimer:LeftTillSimMS(STime) > 0 then
      FrameMan:ClearScreenText(Activity.PLAYER_1);
      FrameMan:SetScreenText("STORM IN " .. math.ceil(StormTimer:LeftTillSimMS(STime)/1000) .. " SECONDS", Activity.PLAYER_1, 0, 5000, false);
   end

   if StormTimer:LeftTillSimMS(STime) < 500 and StormTimer:LeftTillSimMS(STime) > -500 then
      FrameMan:ClearScreenText(Activity.PLAYER_1);
      FrameMan:SetScreenText("oh god what is happening how did this get here", Activity.PLAYER_1, 0, 5000, false);
   end

   if StormTimer:LeftTillSimMS(STime) < 0 then
      if math.random() < intensity then
         local SandP = CreateMOPixel("Sand Particle");
         SandP.Pos = Vector(0,math.random(SceneMan.Scene.Height/2));
         SandP.Vel.X = -math.random(150) - 50;
         SandP.Team = -1;
         MovableMan:AddMO(SandP);
      end
      if StormTimer:LeftTillSimMS(STime) < -5000 then
         StormTimer:Reset();
         STime = math.random(10000) + 45000;
      end
   end
end

Author:  Mind [ Fri Jul 10, 2009 7:34 pm ]
Post subject:  Re: I'm having trouble with a script, help please

STime = math.random(30000) + 45000;

STime = storm time?

Author:  Foogooman [ Fri Jul 10, 2009 8:15 pm ]
Post subject:  Re: I'm having trouble with a script, help please

Mind wrote:
STime = math.random(30000) + 45000;

STime = storm time?


That's what I thought too but those are variables for the time in between storms.

Author:  TheLastBanana [ Fri Jul 10, 2009 11:05 pm ]
Post subject:  Re: I'm having trouble with a script, help please

Code:
if StormTimer:LeftTillSimMS(STime) < -5000

That's the line right here. LeftTillSimMS returns how long, in simulation time milliseconds, until something happens. This code is contained in a block that checks if STime has already passed, so this will give a negative result. So, -5000 is 5 seconds. If you wanted the storm to last 30 seconds, you would change it to -30000.

Author:  Geti [ Fri Jul 10, 2009 11:52 pm ]
Post subject:  Re: I'm having trouble with a script, help please

mopixels dont have teams.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/