and the answer is: nadda. I can click on it, but nothing happens.
And the log still shows the same as above.
I'm going to paste my script files. I know it's got to be me doing something wrong:
In the interest of saving space, I'm leaving the glue out of each file.
Campbravo.py
Code: Select all
# emacs-mode: -*- python-*-
from Plasma import *
from PlasmaTypes import *
from PlasmaNetConstants import *
from xPsnlVaultSDL import *
import math
import time
#variables:
class Campbravo(ptResponder,):
__module__ = __name__
def __init__(self):
ptResponder.__init__(self)
self.id = 51020001
self.version = 1
self.AgeName = None
def OnFirstUpdate(self):
pass
def OnServerInitComplete(self):
pass
def OnNotify(self, state, id, events):
pass
def OnSDLNotify(self, VARname, SDLname, playerID, tag):
pass
def OnTimer(self, id):
pass
CampbravoBookGUI.py
Code: Select all
######################################
# #
# Dynamic Book Template by D'Lanor #
# #
######################################
from Plasma import *
from PlasmaTypes import *
from PlasmaNetConstants import *
import xLinkingBookDefs
import CampbravoPageDefs
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')
AgeStartedIn = None
ourBook = None
bkLinks = []
ageBooks = ('welcomebk')
bookPages = ('cbjournal1')
class CampbravoBookGUI(ptModifier,):
def __init__(self):
ptModifier.__init__(self)
self.version = '1'
print ('__init__%s v.%s' % (self.__class__.__name__, self.version))
def OnFirstUpdate(self):
global AgeStartedIn
print ('%s: OnFirstUpdate called' % self.__class__.__name__)
AgeStartedIn = PtGetAgeName()
def OnNotify(self, state, id, events):
global ourBook
global bkLinks
print ('%s: OnNotify called' % self.__class__.__name__)
if ((id == actClickableObject.id) and state):
print 'Someone clicked an object'
if (PtWasLocallyNotified(self.key)):
print 'It was you'
for i in range(0, len(ageBooks)):
if (ObjectMsg.value == ageBooks[i]):
print ('%s found! Start opening...' % ageBooks[i])
self.IOpenBook(bookPages[i], 0)
break
###################################################################################################
# Pagenames in bookPages must be defined in the __YourAge__PageDefs file. #
# #
# Opening the book with forceOwned set to 1: the code checks if the original book has been found. #
# A player who does not own the age will not see the linking panel. By default forceOwned is off! #
# If you need this restriction simply use: self.IOpenBook(bookPages[i], 1) #
# #
# In case of multiple books the code will find any books automagically. You can add as many books #
# as you like. Just define them in the global variables ageBooks and bookPages and make sure that #
# their order in both variables matches. #
###################################################################################################
else:
for event in events:
if (event[0] == PtEventType.kBook) and (PtWasLocallyNotified(self.key)):
print('BookNotify event=%d, id=%d' % (event[1], event[2]))
if (event[1] == PtBookEventTypes.kNotifyImageLink):
if (event[2] >= xLinkingBookDefs.kFirstLinkPanelID):
print('BookNotify: hit linking panel %s' % event[2])
ourBook.hide()
for i in range(0, len(bkLinks)):
if (event[2] == bkLinks[i][0]):
try:
self.IlinkToAge(bkLinks[i][1], bkLinks[i][2], bkLinks[i][3], bkLinks[i][4])
except Exception, detail:
print('ERROR: Unable to initialize link - %s' % (detail))
break
elif (event[1] == PtBookEventTypes.kNotifyShow):
print('Show Book')
PtSendKIMessage(kDisableKIandBB, 0)
elif (event[1] == PtBookEventTypes.kNotifyHide):
print('Hide Book')
PtSendKIMessage(kEnableKIandBB, 0)
elif (event[1] == PtBookEventTypes.kNotifyNextPage):
print('To Next Page %d' % (ourBook.getCurrentPage()))
elif (event[1] == PtBookEventTypes.kNotifyPreviousPage):
print('To Previous Page %d' % (ourBook.getCurrentPage()))
elif (event[1] == PtBookEventTypes.kNotifyCheckUnchecked):
print('Relto Page Toggled')
elif (event[1] == PtBookEventTypes.kNotifyClose):
print('Close Book')
def IOpenBook(self, bkPages = None, forceOwned = 0):
global ourBook
global bkLinks
print ('%s: IOpenBook: Page request for %s' % (self.__class__.__name__, bkPages))
if (type(bkPages) == type(None)):
return
PageDef = CampbravoPageDefs.BookDef + CampbravoPageDefs.BookFont
PageCount = xLinkingBookDefs.kFirstLinkPanelID
bkLinks = []
for bkPage in bkPages:
if (not bkPage in CampbravoPageDefs.LinkDestinations):
print ('skipping %s because definition does not exist' % bkPage)
continue
# setting up the destination from the definition
params = CampbravoPageDefs.LinkDestinations[bkPage]
(bkAge, spawnPoint, spTitle, linkRule,) = params
alink = 1
if (type(bkAge) != type(None) and forceOwned):
print ('ownership check for %s book' % bkAge)
vault = ptVault()
ainfo = ptAgeInfoStruct()
ainfo.setAgeFilename(bkAge)
alink = vault.getOwnedAgeLink(ainfo)
if alink:
print ('showing page for %s' % bkAge)
if (type(bkAge) != type(None)):
t = (PageCount, bkAge, spawnPoint, spTitle, linkRule)
bkLinks.append(t)
PageDef = PageDef + CampbravoPageDefs.BookPages[bkPage] % (PageCount) + '<pb>'
else:
PageDef = PageDef + CampbravoPageDefs.BookPages[bkPage] + '<pb>'
PageCount = PageCount + 1
else:
print ('No %s book on your shelf so we are not showing the link' % bkAge)
if (PageCount == xLinkingBookDefs.kFirstLinkPanelID):
print 'no pages created'
return
print ('linkingpages created: %d' % (len(bkLinks)))
PageDef = PageDef[:-4]
ourBook = ptBook(PageDef, self.key)
ourBook.setSize(1.0, 1.0)
ourBook.setGUI('BkBook')
ourBook.show(0) # 0 = closed book, 1 = open book
def IlinkToAge(self, ageName, spawnPoint, theTitle = None, linkRule = PtLinkingRules.kBasicLink):
print ('%s: ILinkToAge: Link request for age %s' % (self.__class__.__name__, ageName))
als = ptAgeLinkStruct()
ainfo = ptAgeInfoStruct()
ainfo.setAgeFilename(ageName)
ainfo.setAgeInstanceName(self.IConvertAgeInstanceName(ageName))
als.setAgeInfo(ainfo)
if (type(theTitle) != type(None)):
spTitle = theTitle
##################################################
# Spawnpoint title is defined. Continue linking. #
##################################################
else:
if ((linkRule == PtLinkingRules.kOriginalBook) or PtIsSinglePlayerMode()):
##############################################################################
# Linkingrule kOriginalBook writes spawnpoint and title to the agelink node, #
# so we must make absolutely sure that a proper title is given! #
# In singleplayer mode all linkingrules behave like kOriginalBook, no matter #
# which linkingrule is set in the definition. #
##############################################################################
if (spawnPoint == 'LinkInPointDefault'):
spTitle = 'Default'
#################################################################################
# We did not define a spawnpoint title, but since the spawnpoint is the default #
# it is safe to continue and write it to the agelink node with default title. #
#################################################################################
else:
print 'Empty spawnpoint title not allowed, check your linking page definitions!'
return
else:
print 'Empty spawnpoint title allowed, continue linking'
spTitle = ''
als.setLinkingRules(linkRule)
spPoint = ptSpawnPointInfo(spTitle, spawnPoint)
als.setSpawnPoint(spPoint)
linkMgr = ptNetLinkingMgr()
linkMgr.linkToAge(als)
print ('Linking to age %s, spawnpoint %s with title %s, using linkingrule %d' % (ageName, spawnPoint, spTitle, linkRule))
def IConvertAgeInstanceName(self, ageName):
#########################################################################################################################
# Optional: You can add a friendly name to this list for the age you link to. This is the name that shows up in the KI. #
# Ahra Pahts and Relto are used here only as examples. #
# Some Cyan age names are converted to friendly names in the KI but we cannot expect the KI to do that for user ages. #
# Beware: Age instance names are written to the vault if the kOriginalBook rule is used. That will happen whether you #
# set a name here or not. And it would happen regardless of this function. #
# By default the age instance name is the same as the age name. #
# btw, if you plan to link to Cyan ages you should set the correct age instance name here. Correct? You figure it out! #
#########################################################################################################################
if (ageName == 'Personal'):
return 'Relto'
if (ageName == 'Pahts'):
return 'Ahra Pahts'
return ageName
CampbravoPageDefs.py
Code: Select all
from Plasma import *
from PlasmaNetConstants import *
# Due to their length journal texts are usually stored in external Python files.
# The line below imports them. Remove this line if you do not use external journals.
from CampbravoJournals import *
# Variables that can be used in BookPages:
# Retrieve local player name in case you want to fake a "personal" note
plyrName = PtGetLocalPlayer().getPlayerName()
# BookDef sets cover and margins of the book. The cover can be the same texture as used for the book object itself.
BookDef = '<cover src="welcomebook"><margin right=32 left=32>'
# BookFont is an example for font attributes.
BookFont = '<font size=12 face=Arial color=000000>'
PageStart = '<pb>'
ImgStart = '<img src="'
TransImgStart = '<img opacity=0.7 src="'
ImgEnd = '" align=center link=%d blend=alpha>'
ImgEndNoLink = '" align=center blend=alpha>'
AlignCenter = '<p align=center>'
AlignLeft = '<p align=left>'
AlignRight = '<p align=right>'
###############################################################################
# LinkDestinations Section: #
# 1 = any name (this is used to call the definitions) #
# 2 = age name #
# 3 = spawnpoint #
# 4 = spawnpoint title #
# 5 = linkingrule #
# #
# Notes: - Variables for journals are dummies and must be set to None. #
# - Spawnpoint title None is only allowed for LinkInPointDefault #
# (although it would be better to set it to 'Default' in that case). #
# - CleftDrop in this example will deliberately fail (see above). #
###############################################################################
LinkDestinations = {'cbjournal1': (None, None, None, None)}
###############################################################################################
# BookPages Section: #
# 1 = Same names as used under link destinations! #
# 2 = The page layout: for linking books insert the name of your linking panel image here. #
# This can be a seperate texture in your age prp file not used by a Blender object #
# (not sure if Blender handles that: use PRP Explorer). #
# Once you get the hang of this you can mix and match layouts into your pages. #
# #
# Notes: - AlignCenter is used to center text, for example to place below a linking panel. #
###############################################################################################
BookPages = {'cbjournal1': (PageStart + Defjournal1cont)}
CampbravoJournals.py
(please note, the journal contents are all on one line.)
Code: Select all
# Examples of journals. DefFontTest shows the fonts available in the offline version.
Defjournal1cont = '<margin right=30 left=44 top=63 bottom=23><font size=16 face=Courier>\nWelcome to Camp Bravo! /n/n You are well on your way to becoming a Maintainer in learning how to inspect an Age. \n There are many things to look for while in an Age, and we will be showing you both what to look for and how to look for it. \n\n But first, here is some background about this Age. <pb>Camp Bravo is situated on a world which is a satellite of the ringed gas giant Angmar -- you will sometimes see Angmar in the sky after linking here, depending on the time of day or night. \n Angmar orbits a sun-like star at the same distance as the Earth orbits the Sun. This, along with a thick atmosphere, ensures a stable temperature here at Camp Bravo. \n Camp Bravo is on one of five moons in orbit around Angmar. The other four moons appear to be small and rocky, like Earth\'s moon. <pb> Statistics of Camp Bravo. \n\nGravity -- 0.92 Earth Norm. \n Atmospheric Pressure -- 1012 mb \n Atmospheric content -- 20% oxygen, 78% nitrogen <pb> After linking in, a team of Maintainers explored as much of this Age\'s surface as possible. No inhabitants were found, nor the remains of any that we know of. \n Animal life is limited to some small bird-like creatures and small reptiles. \n As most of the surface appears to be rocky desert, there is not much vegetation. \n This may have been different in the past as some coal deposits have been found. <pb> Please remember to keep your Relto linking book with you at all times. \n We hope your stay here will be interesting.'