Page 1 of 3

clickable objects, again.

PostPosted: Fri Dec 14, 2007 11:17 am
by andylegate
Hey guys, thought I'd bring this back up as no one was able to, or had time to, or didn't see my original question:

How do you make it to where you have more than one clickable object? Let me explain:

I know how to make the Area in Blender and make it clickable, the question is not that. The question is how to make more than one object clickable in the scripting. Here is an example:

Let us say I have TWO journals that I want explorers to read. The tutorial on creating A journal is great and it works. But for adding more than one, it just says "you should repeat the code"
And that does not help at all! It doesn't say what code or how.

Next question about it. Now let's say I have other things that I want the explorer to be able to click on and either read or get a closer look. A good example of this Sharper's desk in the Baron's Office. There is a journal to read, but there are also notes, and maps, each one you can click on to bring it up to look at.

Anyone have a better idea about this yet?

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 11:40 am
by Aloys
I wrote the tutorial, but I had no idea it would be difficult to have more than one journal... Honnestly I don't even think I gave it much thought.. At any rate I have no idea, I wrote the tutorial, but I am not a Python specialist. However I am sure one of our fine codes will come with the answer before the end of the day.. :)

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 11:54 am
by D'Lanor
You simply distinguish the objects by their names.

Code: Select all
....
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectName = None
class BlahBlah(ptModifier,):

    def OnFirstUpdate(self):
        global ObjectName
        ObjectName = self.sceneobject.getName()


    def OnNotify(self, state, id, events):
        if ((id == actClickableObject.id) and state):
            print 'Someone clicked an object'
            if (PtWasLocallyNotified(self.key)):
                print 'It was you'
                if (ObjectName == 'JournalA'):
                    ....
                if (ObjectName == 'JournalB'):
                    ....

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 12:05 pm
by Robert The Rebuilder
...and make sure you indent your code properly; note in D'Lanor's example how the elipses are indented. From what I recall in your last post, Andy, it was unclear how the per-clickable-object code was indented, but it seemed as if they were at the same indent level as the 'if' clause.

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 12:09 pm
by andylegate
Okay guys, I'll give it a swing and see what happens.

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 4:06 pm
by andylegate
Okay......that didn't work.

What it did was crash me to my desktop. Now, I know the code will work for a Journal, as I used it in my first little Age I did, just fine.

I wasn't sure if I was adding a second object correctly, so I put it down to one object: again, crashed to the desktop.

Now, I raised this question in my other post before: uam.showBook or uam.showNotebook. I don't know if either of those codes will work if the object is NOT a journal. I'm trying to make it to where a note pops up. There are no other tutorials.

If you look at what D'lanor put up there in the post above, he's not showing the code for anything either.

Here's the script I made:

Code: Select all
def OnNotify(self, state, id, events):
        uam.handleNotify(state, id, events)
        if (id == actClickableObject.id):
            if (ObjectMsg.value == 'note1'):
                uam.showBook('<img src="note1" align=center resize=no>', self.key)


note1 is both the name of the object, and my pictures is also note1.jpg

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 4:10 pm
by Nadnerb
The showBook function can't be used for anything besides books with pages and such. There currently doesn't seem to be a way to show an arbitrary texture as a GUI like you apparently want to do. I think you'd have to make a GUI file and somehow call that up, but I'm not familiar with that, and I'm not sure it's possible anyway.

Also, there's a missing close parenthesis in that last line of that code quote.

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 4:15 pm
by andylegate
The missing paren is there, I just didn't highlight that far.

Sigh......this sucks. not everything is in a journal......

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 4:43 pm
by Jennifer_P
Hmm...You know the one night Age where you press the hand buttons and it opens doors or displays the nebula on the ceiling (ever talk about that Age over at the GoA, Andy?)? How did the people who made that Age do it? They might be able to help you out.

Re: clickable objects, again.

PostPosted: Fri Dec 14, 2007 5:45 pm
by Chacal
Jonae. Yes, the German team is quite advanced.