I don't know quite where to start

I need to make a simple script that takes the object it collides with and sets the objects name as a target for another object to edit this is in the *'s and underlined and italic and bold…

Item 1/ collider
so collision with valid target for x frames-> set property on collider “Target” so item 2 knows who to copy
send message to Item 2. Editor Copy

Item 2/Editor
message copy ------> Set “target” and copy properties “prop 1”, “prop 2”, “prop 3”

display “target” property on a in game text box like “prop 1” on target motor =" torque 1 unit of force"

have one key that is a + symbol and a - symbol that when clicked they cycle through a list of available options for that property like “torque 2 units of force” while changing the property to that item, so if you walk away from what you are editing, it stays how you left it ,

Here is what I have, and my broken python :slight_smile:


Current.blend (430 KB)

I’m not a great fan of how you’ve layed out your python, but that’s OK, as long as you can read it. Here’s what I would do:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

colSens = cont.sensors['Collision']
hitOb = colSens.hitObject #Alternately, get a list with colSens.hitObjectList() and then pick one from it by property etc.

own['target'] = hitOb

The only problem with your code is that you haven’t got the correct Sensor name.
In your script, you are looking for a sensor called ‘NameOfCollisionSensor’ while your sensor is simply called ‘Collision’
Other than that, the only difference between our scripts is formatting (go read PEP008 for tips on readable code)

This particular error should be quite easy to track down in the console. The error it gives reads:

Traceback (most recent call last):
File “Text”, line 9, in <module>
KeyError: ‘requested item “NameOfCollisionSensor” does not exist’

Can you see where that error comes from now?

thank you :slight_smile:

Now it is working no errors, but the text does not change ,
here is what I have, I copied your code and editied it to see if it was a format issue, I think I am just doing it wrong, I want the text to say the name of the object,

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

colSens = cont.sensors[‘Collision’]
hitOb = colSens.hitObject #Alternately, get a list with colSens.hitObjectList() and then pick one from it by property etc.

own[‘Target’] = hitOb


Current.blend (430 KB)

Ok, I think that I am storing a key type and trying to display a string,

just had to store the key, and then do
I am silly

Ok now that I have the key of the item I wish to edit,
how do I have another objects copy property actuator target the key ?
I can pass the variable easy enough,
what I need is to use the property “TargetKey” to decide who “Viewer” copies “property Alpha”
and then later I need to use the add to property actuator to change the" property Alpha" in the “Target” object

Nope, it’s a case that nowhere in the script does it tell that text object to display the name. To do that you’d have to get the object, and write to it. Easy enough:

textObj = [o for o in bge.logic.getCurrentScene.objects if 'Text' in o][0] #Get the display object by a property 'text'
textObj['Text'] = hitOb.name

I hadn’t read your post, but I skipped the copy property actuator, and just wrote straight to the text object’s property from the script.
From a script you can access any objects anything (except for activating actuators, and reading sensor values. But you can edit actuators and sensors)

Here is what I have so far, now the key is valid, now I need to use it to change who another text is looking at,


Current.blend (426 KB)

Seeing as we are both typing at the same time, try heading over to my IRC channel. I’ll be on for another half an hour or so.

I am writing a system for editing properties in game, so I need to select an item (collision) feed the target to the other text(not yet made) and then use it to display the copied property off the new item, then I need to make two buttons per property that I am setting, that I can use to cycle though options on that property, so I will have to do a list of acceptable options for each property, and another list that is the corresponding value to the text,

Do you need anything for any of your games?

Here’s a script that will diplay the objects properties and name:

import bge

GL = bge.logic

cont = GL.getCurrentController()

own = cont.owner

target = bge.logic.getCurrentController().sensors["Sensor"].hitObject

disp = ''
for prop in target.getPropertyNames():
    disp += str(prop)+': '+str(target[prop]) +'
own['Target']= target.name + '
' + disp

It works by getting the list of property names, and then creating a long string out of them.

As for making buttons to click on the strings, that is very very hard. I’ve just spent a few weeks developing a system of doing that for my game’s keymapper, but it’s not flexible enough to be applied here.

What I did was to create overlay objects for each line of text. Then I could get the line number that was clicked, and what was on the line. Then I could edit the line.
However, it was very poorly coded. I could write a script for this case, and it would be better than the one I’m currently using, but I’m not too keen to. (At least, not at this time of night!)

+5 Karma
->sdfgeoff :slight_smile:

Ok now, to move onto editing whichever object is selected’s properties,

ok now I just have

collision propXPlus ----------and------------X=X+1

collision propXNeg ----------and------------X=X+(-1)

Now how do I modify a actuator based on a property? can I use expressions like X in the add to property?