Tips & Tricks: Server-Side HTML

  • plamzi
  • plamzi's Avatar Topic Author
  • Offline
  • Administrator
19 Jan 2014 19:36 #1 by plamzi
Tips & Tricks: Server-Side HTML was created by plamzi
If you're using the default ScrollView, and you recognize the Portal app via one of the ways in which it announces itself (TTYPE, GMCP, MSDP), then you have the option to send HTML directly from the server that will be rendered inside the ScrollView.

Just remember to preface every < and > character in the string with TELNET ESC (ASCII decimal 27/hex 0x1B/octal 033) so the app will treat it as a literal.

Uses include but are not limited to the following:

* Display an image in your splash screen instead of ANSI art:
if (IS_PORTAL(ch))
        send_to_char("\x1b<img src='' \x1b>", ch);

* Play sound effects or music when a certain game event occurs. You can play your own web-facing sounds, as long as the URL is good, and the file is in a format supported by a user's HTML5-capable browser.
if (IS_PORTAL(ch))
        send_to_char("\x1b<audio src='app/sound/ding.mp3' autoplay\x1b>\x1b</audio\x1b>", ch);

* Add a hover tooltip to any text:
if (IS_PORTAL(ch))
        send_to_char("\x1b<a href='#' class='tip' title='Shovels can be used to \'dig\' and \'whack\' someone.' \x1b>A shiny shovel is lying here.\x1b</a\x1b>", ch);

* Load any other HTML / HTML5 element, such as a nicely formatted link, tutorial video, or a static game map image loading whenever a Portal player types 'map' in a place for which you have a static map.

* Currently, it is possible to execute JavaScript by sending it inside a <script> tag. This means you can send your customizations directly from the server without having to have Official code running on the Portal app page.

That said, the recommended practice is to use the site authoring framework for the most flexibility in authoring, co-authoring, and allowing your end users to load their own customizations.
The topic has been locked.