Difference between revisions of "Template:JumpMap from World"

From Traveller Wiki - Science-Fiction Adventure in the Far future
Jump to navigation Jump to search
(Created page with "{{JumpMap|{{urlencode:{{#sub: {{#explode: {{#explode: {{#explode:{{{1}}}|(|-1}} |)|0}} |{{!}}|-1}} |0|-7}}}}|{{#explode: {{#explode: {{#explode:{{{1}}}...")
 
Line 4: Line 4:
 
       {{#explode:{{{1}}}|(|-1}}
 
       {{#explode:{{{1}}}|(|-1}}
 
     |)|0}}
 
     |)|0}}
   |{{!}}|-1}}
+
   |{{!}}|0}}
|0|-7}}}}|{{#explode:
+
|2|-7}}}}|{{#explode:
 
   {{#explode:
 
   {{#explode:
 
     {{#explode:{{{1}}}|(|-1}}
 
     {{#explode:{{{1}}}|(|-1}}
Line 12: Line 12:
 
[[Category: Templates]]
 
[[Category: Templates]]
 
This is the intermediate template to convert the output of the [[Template:World]] or [[Template:WorldS]] into the parameters required for [[Template:JumpMap]].  
 
This is the intermediate template to convert the output of the [[Template:World]] or [[Template:WorldS]] into the parameters required for [[Template:JumpMap]].  
 +
 +
The JumpMap requires two parameters: A sector name (unadorned) and a hex location within the sector.
 +
 +
Since both the World and WorldS templates produce this information in the form of (<Sector Name> <Hex Location>)
 +
 +
The #explode splits a string (the output of the templates in this case) into two parts and returns one of the parts.
 +
 +
The inner most #explode split the string on a "(", and returns the last piece.
 +
The next #explode splits the string on a ")" and returns the first piece.
 +
 +
At this point we have a "[[<name> Sector|<name>]] <hex>" string
 +
 +
In the first parameter, the #explode splits the string on a vertical pipe and returns the first piece. The #sub (substring) function then trims the first two characters and the last 7 characters, returning just the <name>. This is #urlencoded as some sector names contain characters which are not allowed in URL.
 +
 +
for the second parameter #explode splits on a space and returns the last value.
 +
 +
{{JumpMap from World|{{World|Vaersngurr|Gvurrdon|Ksits Usathu Odzuetarug| 1830}}}}
 +
 
</noinclude>
 
</noinclude>

Revision as of 12:51, 11 April 2021

This is the intermediate template to convert the output of the Template:World or Template:WorldS into the parameters required for Template:JumpMap.

The JumpMap requires two parameters: A sector name (unadorned) and a hex location within the sector.

Since both the World and WorldS templates produce this information in the form of (<Sector Name> <Hex Location>)

The #explode splits a string (the output of the templates in this case) into two parts and returns one of the parts.

The inner most #explode split the string on a "(", and returns the last piece. The next #explode splits the string on a ")" and returns the first piece.

At this point we have a "[[<name> Sector|<name>]] <hex>" string

In the first parameter, the #explode splits the string on a vertical pipe and returns the first piece. The #sub (substring) function then trims the first two characters and the last 7 characters, returning just the <name>. This is #urlencoded as some sector names contain characters which are not allowed in URL.

for the second parameter #explode splits on a space and returns the last value.