Syntax Highlighting

From Data Realms Wiki

Jump to: navigation, search

Contents


Using highlighting

A new form of syntax highlighting has been implemented into the wiki.

Many codetags are available, such as:

 <lua>, <php>, <fortran>, <freebasic>, <vb> 

The main one you should care about on this wiki is, of course, the Lua tag. Following is an example of literal text you would enter:

<lua>
    --------------------------
    -- Set up players
    
    for player = 0, self.PlayerCount - 1 do
        -- Check if we already have a brain assigned
        if not self:GetPlayerBrain(player) then
            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
                self.ActivityState = Activity.EDITING;
                AudioMan:ClearMusicQueue();
                AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1);
            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
</lua>

When enclosing something in lua tags, links to articles for any functions used are automatically added to the code. Example:

 
    --------------------------
    -- Set up players
 
    for player = 0, self.PlayerCount - 1 do
        -- Check if we already have a brain assigned
        if not self:GetPlayerBrain(player) then
            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
                self.ActivityState = Activity.EDITING;
                AudioMan:ClearMusicQueue();
                AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1);
            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
 

Advanced tagging(RECOMMENDED)

If you want your code tag to look as good as Data, it is recommended to use advanced formatting.

Here's an example using the same code from before:

Raw:

<code lua n>
    --------------------------
    -- Set up players
    
    for player = 0, self.PlayerCount - 1 do
        -- Check if we already have a brain assigned
        if not self:GetPlayerBrain(player) then
            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
                self.ActivityState = Activity.EDITING;
                AudioMan:ClearMusicQueue();
                AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1);
            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
</code>


Processed:

  1. --------------------------
  2.     -- Set up players
  3.    
  4.     for player = 0, self.PlayerCount - 1 do
  5.         -- Check if we already have a brain assigned
  6.         if not self:GetPlayerBrain(player) then
  7.             local foundBrain = MovableMan:GetUnassignedBrain(self:GetTeamOfPlayer(player));
  8.             -- 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
  9.             if not foundBrain then
  10.                 self.ActivityState = Activity.EDITING;
  11.                 AudioMan:ClearMusicQueue();
  12.                 AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/ccambient4.ogg", -1, -1);
  13.             else
  14.                 -- Set the found brain to be the selected actor at start
  15.                 self:SetPlayerBrain(foundBrain, player);
  16.                 self:SwitchToActor(foundBrain, player, self:GetTeamOfPlayer(player));
  17.                 self:SetLandingZone(self:GetPlayerBrain(player).Pos, player);
  18.                 -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observati mode
  19.                 self:SetObservationTarget(self:GetPlayerBrain(player).Pos, player)
  20.             end
  21.         end
  22.     end


As you can see this formatting is much more appealing. The links also underline as they are intended to, 100% of the time. Any more questions can be asked in discussion page, and the tags available can be checked on the versions page.

Personal tools