controlling lights?

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

Re: controlling lights?

Postby Chacal » Mon Feb 04, 2008 12:19 am

We're in a situation where there is an urgent need for functionality from a lot of people, and a tremendous capacity for putting this functionality to good use, test it, report bugs and write docs. So far it seems to be working amazingly well.

As for reverse-engineering, isn't it how eveything we know about age building was discovered in the first place? It seems to be pretty much in our culture.
Chacal


"The weak can never forgive. Forgiveness is an attribute of the strong."
-- Mahatma Gandhi
User avatar
Chacal
 
Posts: 2508
Joined: Tue Nov 06, 2007 2:45 pm
Location: Quebec, Canada

Re: controlling lights?

Postby Grogyan » Mon Feb 04, 2008 2:02 am

Using the bridge lights in Bevin, could that be used as a basis for what you want to do?
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: controlling lights?

Postby D'Lanor » Mon Feb 04, 2008 2:43 pm

I did not have much time yesterday, but I will pick up where I left.

The conditional object should at least contain a lamp. I am not sure if we can combine objects to produce a full fetched conditional lightbulb. Perhaps object groups? Anyway, for now it will be just one lamp object called Lamp01 which has the following Alcscript attached.

Code: Select all
Lamp01:
    quickscript:
        sdl:
            type: "boolshowhide"


Be sure to turn on your AgeSDLHook in the script for your Book (which you'll find in the Text Editor window).

Code: Select all
config:
    agesdlhook: True


Then create your SDL file:

Code: Select all
#==============================================================
# READ:   When modifying an SDL record, do *not* modify the
#   existing record. You must copy and paste a new version
#   below the current one and make your changes there.
#==============================================================

#
# State Description Language for yourage

STATEDESC yourage
{
   VERSION 1
   
VAR BOOL    Lamp01Vis[1]    DEFAULT=0 DEFAULTOPTION=VAULT

}


The default is 0 which means the lamp will be initially off.

Next you have to make a clickable button, for example LightButton01 which activates the Python file LightButton.py. I believe clickables are documented for the new PyPRP so I will not repeat it here.

Finally make your Python file LightButton.py. The basic Python code looks like this:

Code: Select all
from Plasma import *
from PlasmaTypes import *
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')
class LightButton(ptModifier,):

    def __init__(self):
        ptModifier.__init__(self)
        self.version = 'your version here'



    def OnNotify(self, state, id, events):
        if ((id == actClickableObject.id) and state):
            if (not PtWasLocallyNotified(self.key)):
                return
            if (ObjectMsg.value == 'LightButton01'):
                ageSDL = PtGetAgeSDL()
                LampOn = ageSDL['Lamp01Vis'][0]
                if LampOn:
                    ageSDL['Lamp01Vis'] = (0,) #switch lamp off
                else:
                    ageSDL['Lamp01Vis'] = (1,) #switch lamp on
"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: controlling lights?

Postby Goofy » Thu Feb 07, 2008 8:04 am

Grogyan: yes the neighborhoods was what I as looking at. (also had a interesting error with them aswell when importing them) I tried to import the normal neighborhood that we all have and it wouldn't let me, but I imported kirel(neighborhood2) and it had no problem

On the topic, After looking at Kirel(neighborhood2) I've notice that according to the import plugin. They use 2 regions(3 if you count the camera) 1 region is used for the each button and then a larger region around them. They also have emptys for the click sounds and other emptys for something, but not sure what yet. Each individual button region is made into an actor, it also is given bounds of convex hull polytope.

I'm going to try and test it just like they its shown in the hood import. BTW thanks for the scripts and such D'Lanor


Edit: Hey ummm whats with not alowing export when no textures are around? Well atleast thats what I get from an error I'm getting. Heres the error message. I'm using the last plugin before gametap anouncement. not sure of number

Code: Select all
   
 [Draw Interface Cube]
  [Material Material]
   [Layer Material-Tex]
    -> Using default first UV map
Traceback (most recent call last):
  File "<string>", line 176, in open_file
  File "<string>", line 88, in export_age
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alcresmanag
er.py", line 585, in export_all
    plDrawInterface.Export(self,obj,scnobj,name,SceneNodeRef,isdynamic)
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alc_DrawCla
sses.py", line 1549, in _Export
    drawi.data.export_obj(obj,SceneNodeRef,isdynamic)
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alc_DrawCla
sses.py", line 1762, in export_obj
    pmat.data.export_mat(mat,obj)
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alc_MatClas
ses.py", line 521, in export_mat
    self.FromBlenderMat(mat,obj)
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alc_MatClas
ses.py", line 417, in FromBlenderMat
    layer.data.FromBlenderMTex(mtex,obj,mat)
  File "C:\Program Files\Blender Foundation\Blender\.blender\scripts\alc_MatClas
ses.py", line 1030, in FromBlenderMTex
    if mface.uv and mface.mode & Blender.Mesh.FaceModes["TWOSIDE"]:
ValueError: face has no texture values


Btw I have no textures at all. Not even UV. I have basic materials, but thats it. I'm just trying to see if things work as I have them(with the clickables.) I shouldn't have to texture everything or anything just to check clickables or other things. well thats if what its complaining about is a texture. seems to me it is.
Also whats with making everything shadeless? Makes it hard to see anything.
We keep moving forward,
openning up new doors and doing new things,
Because we're curious... and curiosity keeps
leading us down new paths

Walt Disney

Keep moving forward
Goofy
 
Posts: 162
Joined: Mon Oct 01, 2007 8:51 pm

Re: controlling lights?

Postby andylegate » Thu Feb 07, 2008 12:32 pm

The new plug in forces UV Mapping I believe. And when you import one of the Uru Ages, you won't find anything UV Mapped. Not that I remember.

So I think what it's complaining about is the fact that, you have materials, you even have textures that are there, but when you go to export, it's trying to UV map them, and it can't because it doesn't know where to put them.
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
User avatar
andylegate
 
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am

Re: controlling lights?

Postby D'Lanor » Thu Feb 07, 2008 1:09 pm

I consider it a bug. I think the developers got too enthiusiastic about their new texturing tricks. They just can't imagine anyone not using them.
"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: controlling lights?

Postby Trylon » Thu Feb 07, 2008 1:18 pm

Yup, a bug.
I forgot that UV mapping isn't always there....


P.S.
Beetje flauwe opmerking D'Lanor ;)
One day I ran through the cleft for the fiftieth time, and found that uru held no peace for me anymore.
User avatar
Trylon
 
Posts: 1446
Joined: Fri Sep 28, 2007 11:08 pm
Location: Gone from Uru

Re: controlling lights?

Postby Grogyan » Sun Feb 10, 2008 12:55 am

Its interesting Goofy that you brought up this question, as its really a reference for how to implement conditions on objects.

I am going to soon try and get the sound of a generator to startup and stay on at the touch of a button and turn off via the same button, so i'm trying to understand the python coding that D'Lanor suggests
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: controlling lights?

Postby andylegate » Sun Feb 10, 2008 7:50 am

Grogyan, if you figure that out, make sure you post what you did and how. That would be a very important asset: Triggered Sounds.

While the sound regions are great for getting a sound to start and stop, there is still not a way for making a sound happen when you interact with something: pulling a lever, button click, etc. Also things like, moving a chair around, and having a scraping sound
"I'm still trying to find the plKey for Crud!"
Image
Blender Age Creation Tutorials
3DS Max Age Creation Tutorials
User avatar
andylegate
 
Posts: 2348
Joined: Mon Oct 01, 2007 7:47 am

Re: controlling lights?

Postby Trylon » Sun Feb 10, 2008 7:53 am

Grogyan wrote:I am going to soon try and get the sound of a generator to startup and stay on at the touch of a button and turn off via the same button, so i'm trying to understand the python coding that D'Lanor suggests


Just a quick note: I believe that this can be done entirely without using python.
One day I ran through the cleft for the fiftieth time, and found that uru held no peace for me anymore.
User avatar
Trylon
 
Posts: 1446
Joined: Fri Sep 28, 2007 11:08 pm
Location: Gone from Uru

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron