//myRPG.jsx //An InDesign CS5 JavaScript /* October 2010 */ // This is the first start of a script for a simple computer role-playing game. // The users task is it to find its way from home to the university campus. // While traveling the user has to answer questions which are effecting its destiny. // Going through the questions step by step the InDesign document builds up a text frame describing the user's journey. // An info-graphic on the bottom of the document will show the user's journey. // After completing all quest the user can print the file as an A3 document. // // // myRPG.jsx by AnitaMei is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. // Based on a work at https://gist.github.com/3874630 // //***+++RUN SCRIPT+++*** //build page var p = page(); // run indesign in presenation mode (source: forums.adobe.com/message/3398986#3398986) app.activeWindow.screenMode = ScreenModeOptions.PRESENTATION_PREVIEW; // alert introduction if (p == 0) { introduction(); } // ***+++START+++*** function page () { // create new document var myDocument = app.documents.add({ documentPreferences: { pageWidth : 297, pageHeight : 420, facingPages : false } }); // ***+++CYAN RECTANGLE+++*** // create new page item rectangle var myRectangle = myDocument.rectangles.add({ // set geometric bounds (top, left, bottom, and right edges) geometricBounds : ["0mm", "0mm", "420mm", "297mm"], fillColor : "Cyan" }); // ***+++TEXT FRAME 1+++*** // create new text frame var myTextFrame1 = myDocument.pages.item(0).textFrames.add({ // set geometric bounds (top, left, bottom, and right edges) geometricBounds : ["12mm", "12mm", "30mm", "82mm"] }); // add text to the text frame myTextFrame1.contents = "Start…"; // format myTextFrame // (source: indesignscript.de/forum.html?&tx_mmforum_pi1[action]=list_post&tx_mmforum_pi1[tid]=88) var myParentStory = myTextFrame1.parentStory; var countCharacters = myParentStory.characters.length; for (var i=0; i