Code Problem

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Code Problem

Postby cskid13 » Thu Feb 23, 2012 7:05 am

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)
cskid13
 
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Code Problem

Postby D'Lanor » Thu Feb 23, 2012 11:14 am

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
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Code Problem

Postby cskid13 » Thu Feb 23, 2012 11:25 am

Thanks. I forgot that I changed Personal to Payiferen.
cskid13
 
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Code Problem

Postby diafero » Thu Feb 23, 2012 12:21 pm

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
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Code Problem

Postby cskid13 » Thu Feb 23, 2012 12:40 pm

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.
cskid13
 
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Code Problem

Postby diafero » Thu Feb 23, 2012 2:39 pm

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
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Code Problem

Postby Tsar Hoikas » Sat Feb 25, 2012 6:11 pm

Why not just use ptNetLinkingMgr().linkToMyPersonalAge()? Playing with custom links is somewhat dangerous...
Image
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Code Problem

Postby cskid13 » Mon Feb 27, 2012 9:09 am

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.)
cskid13
 
Posts: 228
Joined: Tue Feb 01, 2011 4:19 pm
Location: Eder Tsogal

Re: Code Problem

Postby diafero » Mon Feb 27, 2012 12:36 pm

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
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 13 guests

cron