Page 1 of 1

Code Problem

PostPosted: Thu Feb 23, 2012 7:05 am
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)

Re: Code Problem

PostPosted: Thu Feb 23, 2012 11:14 am
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.

Re: Code Problem

PostPosted: Thu Feb 23, 2012 11:25 am
by cskid13
Thanks. I forgot that I changed Personal to Payiferen.

Re: Code Problem

PostPosted: Thu Feb 23, 2012 12:21 pm
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.

Re: Code Problem

PostPosted: Thu Feb 23, 2012 12:40 pm
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?

Re: Code Problem

PostPosted: Thu Feb 23, 2012 2:39 pm
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 ;-)

Re: Code Problem

PostPosted: Sat Feb 25, 2012 6:11 pm
by Tsar Hoikas
Why not just use ptNetLinkingMgr().linkToMyPersonalAge()? Playing with custom links is somewhat dangerous...

Re: Code Problem

PostPosted: Mon Feb 27, 2012 9:09 am
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.)

Re: Code Problem

PostPosted: Mon Feb 27, 2012 12:36 pm
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 :)