Code Problem

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.
Post Reply
cskid13
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
MOULa KI#: 0
Location: Eder Tsogal

Code Problem

Post by cskid13 »

I am making an age called Skartov, and in it I have a sphere that is supposed to link to Relto. I know that the AlcScript is correct, but I do not know if the python is correct. It is a file called Skartov_IcoLink1.py in Skartov.pak:

Code: Select all

from Plasma import *
from PlasmaTypes import *
from PlasmaNetConstants import *

actClickableObject = ptAttribActivator(1, 'Clickable object activator')
strObject = ptAttribString(2, 'Object string')

class Skartov_IcoLink1(ptModifier,):

    def OnNotify(self, state, id, events):
        if ((id == actClickableObject.id) and state):
            print ('Object %s was clicked' % strObject.value)
            #place your code here
            agelink = ptAgeLinkStruct()
            ageinfo = ptAgeInfoStruct()
            ageinfo.setAgeFilename("Payiferen")
            spawnpoint = ptSpawnPointInfo("Name","LinkInPointDefault")
            agelink.setAgeInfo(ageinfo)
            agelink.setLinkingRules(PtLinkingRules.kOriginalBook)
            agelink.setSpawnPoint(spawnpoint)
            linkmanager = ptNetLinkingMgr()
            linkmanager.linkToAge(agelink)
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Code Problem

Post by D'Lanor »

To Relto or to Payiferen? For Relto you should set...

Code: Select all

            ageinfo.setAgeFilename("Personal")
            ageinfo.setAgeInstanceName("Relto")

For Payiferen the instance name doesn't matter because it is the same as the age name.

As spawn point info you should use ("Default","LinkInPointDefault")

And if you are linking to Relto you can use PtLinkingRules.kOwnedBook which is a safer method for existing ages. It won't overwrite anything in the vault, contrary to PtLinkingRules.kOriginalBook which can mess up your links.
"It is in self-limitation that a master first shows himself." - Goethe
cskid13
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
MOULa KI#: 0
Location: Eder Tsogal

Re: Code Problem

Post by cskid13 »

Thanks. I forgot that I changed Personal to Payiferen.
diafero
Deep Island Admin
Posts: 2972
Joined: Mon May 05, 2008 5:50 am
MOULa KI#: 0
Location: Germany

Re: Code Problem

Post by diafero »

Since you are writing the python manually anyway, the most comfortable way to link to an age is using the xLinkMgr shipped with the Offline KI. If it is okay for you to make the Offline KI a dependency of your age (almost everybody will have installed it anyway), use the following Python code to link to Relto:

Code: Select all

import xLinkMgr
xLinkMgr.LinkToAge("Personal")


This will make sure you use all the correct linking settings and so on (there's a whole lot one can do wrong here, unfotunately). It will also set the spawn point to be whatever is the default spawn point of the age you gave it, unless you pass it as a second parameter.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
cskid13
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
MOULa KI#: 0
Location: Eder Tsogal

Re: Code Problem

Post by cskid13 »

EDIT: I know why I can't link when I click the sphere! How do I attach my dummy python file to an object in Blender?
Last edited by cskid13 on Fri Feb 24, 2012 8:32 am, edited 1 time in total.
diafero
Deep Island Admin
Posts: 2972
Joined: Mon May 05, 2008 5:50 am
MOULa KI#: 0
Location: Germany

Re: Code Problem

Post by diafero »

That should be done by your alcscript, for which I am not an expert at all, sorry.

Btw, when you edit a post because you answered a question yourself, you should usually leave the question in the post and only attach to it. That way, others can still see what you asked, they might have the same question! Also, reading "I know what the problem is" without a hint about what this was about is kind of confusing ;-)
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
Tsar Hoikas
Councilor of Technical Direction
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
MOULa KI#: 23335
Location: South Georgia
Contact:

Re: Code Problem

Post by Tsar Hoikas »

Why not just use ptNetLinkingMgr().linkToMyPersonalAge()? Playing with custom links is somewhat dangerous...
Image
cskid13
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
MOULa KI#: 0
Location: Eder Tsogal

Re: Code Problem

Post by cskid13 »

Tsar Hoikas wrote:Why not just use ptNetLinkingMgr().linkToMyPersonalAge()? Playing with custom links is somewhat dangerous...

That would work, except for the fact that It will later link to another point within Skartov. (Sorry, I should have specified.)
diafero
Deep Island Admin
Posts: 2972
Joined: Mon May 05, 2008 5:50 am
MOULa KI#: 0
Location: Germany

Re: Code Problem

Post by diafero »

Tsar Hoikas wrote:Why not just use ptNetLinkingMgr().linkToMyPersonalAge()? Playing with custom links is somewhat dangerous...

That would work, except for the fact that It will later link to another point within Skartov. (Sorry, I should have specified.)

Using xLinkMgr is (designed to be) not dangerous. Well, sure I could have made a mistake, but I am using it for all fan-age links on DI Shard since the start, and it seems to work well :)
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
Post Reply

Return to “Scripting”