Two messages two keyboard keys

How do you blueprintrandom make the python script show two messages by pressing two different keyboard keys?


According to your question, I wouls say with two keyboard sensors and two message actuators :wink:

I mean how do you make a npc that asked a question understand the answer to the question in the blender game engine?Could you make a pythonscript example?That is why i asked the previous question.


keypress X-------------------and-----------------add object from another layer invisable static ghost - property=“player_look”

in NPC

State 1
collision with property “player look”----------and---------------State 2

State 2
delay 1 time---------------and-----------------add object textbox- question
___________________________-----------------State 3

State 3
Keypress 1 ---------------and-----------------Do something
Keypress 2--------------- and-----------------Do something else

in textbox
keypress 1-------------and ------end object
keypress 2-------------and ------end object

A typical solution is this:

A) question
The logic selects a “question” text from a list of available “questions”. They are usually context dependent, but can be the same all the time. This depends on you.

first time question: “How do you do?”
second time question:“You again, what can I do for you?”

The dialog system presents this text to the user (in whatever way you want it e.g. as text object).

B) Answer
I know you want to type in something, but this is not really convenient to the user. But it is much more comfortable and easier to implement to present a choice of pre-selected answers.

A) “I’m doing well”
B) “forget it”

So you need the dialog system to select answers the user can chose from (remember in A) the logic itself was choosing).
These answers should be presented to the user (similar to the question). This time the user needs a way to select one of them e.g. by clicking on the text or pressing a specified key.

That’s it. Not really exciting.

The complexity comes in when you define the context of the available questions and answers. E.g.
when it is before 12 am -> “good morning”
else if before 18:00 -> “good afternoon”
else -> “good evening”.
The context includes previously asked questions and answers too. This way you get a dialog or a text sequence. You can have loops but you do not need.

So for now you need:
A) a text presentation system for the npc
B) a text selection presentation system for the user [I guess this is what you mean with your question]
C) a text providing system that provides the texts for A) and B)

While A) and B) shouldn’t be a big deal with logic bricks (or a little bit of Python) C) is usually to complex to be done in Logic bricks.

First you need am easy way to model your dialogs without cluttering it with implementation details. You could use an XML file as mentioned in the other thread (there is a thread in the resource forum). I guess this is a bit over your head right now.
But Python is good as well as it allows to write pretty clean data e.g. by setting up some dictionaries or lists.

If you give an example of what text you want, we could go into more details.

Is this a python solution or a logic brick solution?Because the logic brick solution did not work.I think the blender game engine was getting confused with a lot logic bricks.That is why i want a python solution.

The npc asks,"What is your name?Then you anwer,“My name is etc__.”
Then the npc answers with your name plus how are you.

Then the npc asks,"Would you like to trade your weapon for mine?"It is a very good phaser.Then you anwers yes or no.If you anwers yes then he trades the phaser with you.If you say no he says,“Okay i will see if i can trade it with someone else.”

By the way i am a copy paster i just modify the codes people give me.Because i don’t understand python that well.I did that with python programs.I believe it is easier.What i would like to have is a pythoncode for the blender game engine that i could just add on questions for the npc to ask and selectable answers for each question.I would want to add them on as much as i like.Then learn it later on.

By the way i am a copy paster

How can you be making games when other people have to walk you through this stuff? You seem to ask about every step including very basic if-then-else mechanics. game loops and object interaction?

I believe it is easier.

It’s easier for you but you are outsourcing game development from what you do. It’s not your game if it’s programmed by other people.

Helping you is becoming increasingly difficult while you have some of your game working and you need something working on top of that. Unless you can at least debug the code there’s no use going further this path. Quick copy-paste is not going to work anymore when you have this part from here and this part from there. If you aren’t able to keep track of the code it’s only matter of time before your game setup is beyond comprehension to anyone.

i don’t understand python that well

You should be able to figure out this very basic stuff on your own. I suggest you make simpler games until you do.

Yes I would do this in Python as the pure amount of options will kill you with pure logic bricks.

This one requires an additional task: entering variable data (e.g. the name).

To add this you need a GUI element that allows free text typing and storing the result in a property. I think you can find a logic brick solution for this.

For selling it might be better to have a separate “shop” system as it has different requirements.
But you can use the dialog as introduction to the shop e.g. as Fallout does.

It still is a good example.

This is no big deal as long as you try to discover what the code is doing. But you will see that most code snippets provided are incompatible to each other.

I think the already mentioned thread in the resource forum is the right one for you. I never looked at it and I do not have a dialog solution ready. So I can only give you hints and no ready-to-use solutions.

My first hints are above:
A) the text presentation and
B) the text selection with logic bricks. They should take their input from one or more string properties (do not worry where the text is coming from at this stage).

Additional you need
B1) the free text input which allows to type in a name. The output should go into a property.

But the dialogue system in the resource forum spits out errors into the console when i use the blend.
So do i need the bgui library for blend to work.Maybe that is what i did wrong.I am using 2.68 version of blender.