intfiction.org

The Interactive Fiction Community Forum
It is currently Fri May 24, 2013 5:33 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Aug 22, 2011 1:41 pm 
Offline

Joined: Mon Aug 22, 2011 1:29 pm
Posts: 2
Dear Friends,

I am in need of some assistance. For my current project, I am attempting to create a narrative in which the interactor navigates through the story starting with the hyperlink functionality of Twine, and linking from there, also play in Inform. Thus, as the story progresses, the interactor switches back and forth between the two programs.

Initially, the plan was for Twine part of the game be playable in HTML, so linking to a released Inform project is simple enough...I believe. The real tricky part is linking to websites from Inform.

Please, if anybody may be of assistance, I ask for aid.


Cordially,

a. maus


Top
 Profile Send private message  
 
PostPosted: Mon Aug 22, 2011 5:34 pm 
Offline

Joined: Tue Mar 30, 2010 9:30 pm
Posts: 188
The poster is a student of mine--- I think the biggest technical issue here is how to make a Parchment-targeted Inform 7 project display a hyperlink to an external webpage. If you include actual HTML I believe the engine will convert it to < etc. symbols. Anyone know if there is a way around this?

_________________
Aaron Reed - Creating Interactive Fiction with Inform 7 - Smarter Parser


Top
 Profile Send private message  
 
PostPosted: Mon Aug 22, 2011 5:59 pm 
Offline

Joined: Thu Oct 22, 2009 4:31 pm
Posts: 1137
aaronius wrote:
The poster is a student of mine--- I think the biggest technical issue here is how to make a Parchment-targeted Inform 7 project display a hyperlink to an external webpage. If you include actual HTML I believe the engine will convert it to < etc. symbols. Anyone know if there is a way around this?


Could you surgically insert a little javascript to change the symbols back into entities before "printing" them?

--Erik

_________________
Glimmr: Advanced Graphics for I7
blog | download | bug-tracker


Top
 Profile Send private message  
 
PostPosted: Tue Aug 23, 2011 3:47 am 
Offline

Joined: Tue Dec 25, 2007 10:06 am
Posts: 888
I'm working on a more robust solution, but in the meanwile I hacked together a little script that turns {http://example.com Link name} into a hypertext link.

Edit the main HTML file (if you use the release with an interpreter option it's play.html, otherwise index.html). Add the following script somewhere appropriate, just before the </body> tag at the end is a good place:

Code:
<script>
$( document ).bind( 'TextOutput', function( data ) {
    $( '#content' ).html( $( '#content' ).html().replace( /{(.*?)([\< ].*?)}/g, '<a href="$1" target="_blank">$2</a>' ) );
} );
</script>

This will open the links in a new window. If you want to open the links in the same window just remove the target="_blank" part from the above.

You must also remove the word defer from the script tags that load the libraries at the start of the file:

Code:
  <script src="interpreter/jquery.min.js"></script>
  <script src="interpreter/parchment.min.js"></script>

(these say lib/ instead of interpreter/ if you use the stand-alone Parchment installation.)

This works only in the latest version of Parchment. If you're using the one built into Inform, you have to update the Parchment library files and the jQuery library. Download these files: parchment.min.js, zmachine.min.js and jquery.min.js and replace the old ones in the interpreter directory.

Now you can add hyperlinks in Inform like this:

Code:
Test is a room. "Visit {http://intfiction.org/forum Intfiction.org forums} and {http://ifdb.tads.org IFDB}!"


Remember that this is just a very quick and dirty hack and it's not supposed to be a general solution. Also, because it runs the whole story text through the regex every time it might slow down the interpreter if the transcript is very long, but I suspect it would become a problem only after an hour of play or so. I haven't tested this with Internet Explorer but I don't see a reason why it wouldn't work (although you never know).


Top
 Profile Send private message  
 
PostPosted: Wed Aug 24, 2011 5:30 pm 
Offline

Joined: Mon Aug 22, 2011 1:29 pm
Posts: 2
Juhana,

Thanks a lot. It works, but there's definitely some copying and pasting that needs to be done beforehand, since we needed to keep a copy of the modified files so it wouldn't get overridden by recompiling.


Cordially,


a. maus


Top
 Profile Send private message  
 
PostPosted: Wed Aug 24, 2011 8:41 pm 
Offline
User avatar

Joined: Mon Oct 04, 2010 11:35 am
Posts: 776
Location: Toronto
You might also consider some of these solutions mentioned in these threads if you were not already aware of them.

viewtopic.php?f=7&t=1518

viewtopic.php?f=38&t=1623

Paul.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Emerald, Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group