Syntax Highlighting
From Data Realms Wiki
(Noticed a cautionary tale) |
(Backslashes are fine, wrong tags were in the page. Whoops!) |
||
Line 37: | Line 37: | ||
When enclosing something in lua tags, it provides links back to the functions inside the tags, along with formatting like so: | When enclosing something in lua tags, it provides links back to the functions inside the tags, along with formatting like so: | ||
- | < | + | <lua> |
-------------------------- | -------------------------- | ||
-- Set up players | -- Set up players | ||
Line 60: | Line 60: | ||
end | end | ||
end | end | ||
- | </ | + | </lua> |
- | + | ||
- | + | ||
='''Advanced tagging(''RECOMMENDED'')'''= | ='''Advanced tagging(''RECOMMENDED'')'''= |
Revision as of 17:09, 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, 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.