Syntax Highlighting
From Data Realms Wiki
m (Removed from Tutorials category.) |
m (word choice) |
||
(3 intermediate revisions not shown) | |||
Line 3: | Line 3: | ||
=Using highlighting= | =Using highlighting= | ||
- | A new form of syntax highlighting | + | A new form of syntax highlighting has been implemented into the wiki. |
- | Many codetags are | + | Many codetags are available, such as: |
- | < | + | <PRE> <lua>, <php>, <fortran>, <freebasic>, <vb> </PRE> |
- | The main one you should care about on this wiki is of course the Lua tag. | + | 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: |
- | < | + | <PRE><lua> |
-------------------------- | -------------------------- | ||
-- Set up players | -- Set up players | ||
Line 33: | Line 33: | ||
end | end | ||
end | end | ||
- | </lua></ | + | </lua></PRE> |
- | When enclosing something in lua tags, | + | When enclosing something in lua tags, links to articles for any functions used are automatically added to the code. Example: |
- | < | + | <lua> |
-------------------------- | -------------------------- | ||
-- Set up players | -- Set up players | ||
Line 60: | Line 60: | ||
end | end | ||
end | end | ||
- | </ | + | </lua> |
='''Advanced tagging(''RECOMMENDED'')'''= | ='''Advanced tagging(''RECOMMENDED'')'''= |
Latest revision as of 17:13, 19 June 2012
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:
- --------------------------
- -- 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.