Syntax Highlighting
From Data Realms Wiki
(Difference between revisions)
Revision as of 18:37, 4 June 2010
Contents |
Using highlighting
A new form of syntax highlighting as been implemented into the wiki.
Many codetags are implemented such as:
<lua>, <php>, <fortran>, <freebasic>, <vb>
The main one you should care about on this wiki is of course the Lua tag. It can be used vanilla like so:
<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, it provides links back to the functions inside the tags, along with formatting like so:
-------------------------- -- 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:
- --------------------------
- -- Set up players
- for player = 0, self.PlayerCount - 1 do
- -- Check if we already have a brain assigned
- -- 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;
- else
- -- Set the found brain to be the selected actor at start
- -- Set the observation target to the brain, so that if/when it dies, the view flies to it in observati mode
- end
- end
- 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.