Created
October 11, 2012 18:42
-
-
Save AnitaMei/3874630 to your computer and use it in GitHub Desktop.
MyScript for the Projektwochen 2012/2013 at FH Potsdam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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<countCharacters;i++) { | |
var curCharacter = myParentStory.characters.item(i); | |
curCharacter.appliedFont = app.fonts.item("DIN"); | |
curCharacter.fontStyle = "Bold"; | |
curCharacter.pointSize = 60; | |
curCharacter.tracking = 30; | |
} | |
// ***+++TEXT FRAME 2+++*** | |
// create new text frame | |
var myTextFrame2 = myDocument.pages.item(0).textFrames.add({ | |
// set geometric bounds (top, left, bottom, and right edges) | |
geometricBounds : ["378mm", "140mm", "396mm", "285mm"] | |
}); | |
// add text to the text frame | |
myTextFrame2.contents = "…FH Potsdam"; | |
// format myTextFrame | |
// (source: indesignscript.de/forum.html?&tx_mmforum_pi1[action]=list_post&tx_mmforum_pi1[tid]=88) | |
var myParentStory = myTextFrame2.parentStory; | |
var countCharacters = myParentStory.characters.length; | |
for (var i=0; i<countCharacters;i++) { | |
var curCharacter = myParentStory.characters.item(i); | |
curCharacter.appliedFont = app.fonts.item("DIN"); | |
curCharacter.fontStyle = "Bold"; | |
curCharacter.pointSize = 60; | |
curCharacter.tracking = 30; | |
} | |
// paragraph alignment | |
myTextFrame2.paragraphs.item(0).justification = Justification.RIGHT_ALIGN; | |
// ***+++TEXT FRAME 3+++*** | |
// create new text frame | |
var myTextFrame3 = myDocument.pages.item(0).textFrames.add({ | |
// set geometric bounds (top, left, bottom, and right edges) | |
geometricBounds : ["16mm", "91mm", "157mm", "285mm"] | |
}); | |
// add text to the text frame | |
var myIntroduction = "Es ist Montagmorgen bei dir zu Hause " + | |
"irgendwo in Berlin. Du solltest spätestens um 10 Uhr " + | |
"an der Potsdamer Hochschule sein. Dein Weg durch den " + | |
"Berliner Verkehrsdschungel ist gefährlich. Komme also " + | |
"nicht vom Weg ab."; | |
myTextFrame3.contents = myIntroduction + " +++"; | |
// format myTextFrame | |
// (source: indesignscript.de/forum.html?&tx_mmforum_pi1[action]=list_post&tx_mmforum_pi1[tid]=88) | |
var myParentStory = myTextFrame3.parentStory; | |
var countCharacters = myParentStory.characters.length; | |
for (var i=0; i<countCharacters;i++) { | |
var curCharacter = myParentStory.characters.item(i); | |
curCharacter.appliedFont = app.fonts.item("DIN"); | |
curCharacter.fontStyle = "Medium"; | |
curCharacter.pointSize = 19; | |
curCharacter.tracking = 20; | |
curCharacter.leading = 24; | |
} | |
// paragraph alignment | |
myTextFrame3.paragraphs.item(0).justification = Justification.LEFT_JUSTIFIED; | |
// ***+++CREATE OUTLINES+++*** of all text frames in the document | |
var textFrames = myDocument.textFrames.everyItem().getElements(); | |
for (var i=0; i< textFrames.length; i++) { | |
textFrames[i].createOutlines(false); | |
// move all text frames into the background | |
textFrames[i].sendToBack(); | |
} | |
return 0; | |
} | |
// ***+++ALERT INTRODUCTION+++*** | |
function introduction(){ | |
var myIntroduction = "Es ist Montagmorgen bei dir zu Hause " + | |
"irgendwo in Berlin. Du solltest spätestens um 10 Uhr " + | |
"an der Potsdamer Hochschule sein. Dein Weg durch den " + | |
"Berliner Verkehrsdschungel ist gefährlich. Komme also " + | |
"nicht vom Weg ab."; | |
confirm("Deine Mission" + "\n" + myIntroduction + " Möchtest du beginnen?"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment