How to generate text expression and object name?

Hi.

I would like to store object names and keyboard keys In variables so It possible to change them in game,but it not possible to use variables in key press and create object events.However,when I was request this feature 4ian mentioned that I can still generate text expression and object name from variable but I don’t know how to do that.I have no idea.

I would appreciate any help.

If I understand correctly, you want to instantiate objects by writing their name in a variable.

In “Add action”, “All objects->Objects->create an objet from name” or something like that.
You might need to emulate the keyboard, either through a virtual one you build from scratch, or through direct inputs.
Both solutions ask you one conditionnal per key.

If touch a pressed write +“a” in GlobalVariable(StringForCreateObject)
If touch b pressed write +“b” in GlobalVariable(StringForCreateObject)
If touch c pressed write +“c” in GlobalVariable(StringForCreateObject)

etc.

It might be faster to just offer 5-6 objects to create by choosing a number.

What’s the point of all this anyway?
Are you trying to clone Scribblenauts?

Hi.
Thanks for your help :slight_smile:

My original idea was to store keyboard keys in variables to controll the game.
For example I would create variable forward,left,right…etc and I could store the keys inside this variables and I would use the variables in the key press events to controll the player.This way I could let the player to customize the controlls easily by changing the value of variable through an input menu.I could also save\load the changes easily by writing the value in to a file and read the value back in to variable on load.

The same idea for objects,I would create a variable called player for example and I could store the name of the player object inside this variable and I would use this variable in object events,this way the player can change the player character (or even parts of the charater to customize it) easily by changing the value of the variable through an input\selection menu.

But unfortunately it isn’t possible to use variables this way and for object events it never going to be possible for performace and security reason :frowning:

For the binding controls, you could offer 3 default settings, instead of letting the player bind whatever he likes. Better making it efficient from the get-go. 99% of people will use the standard controls anyway : arrow keys to move, space + wxcv for actions.
Or use joy2key.

For the player, you can switch appareances of a sprite by changing its animation number.
Animation 0 = naked
Animation 1 = leather armor
Animation 2 = iron mail
etc.

To create a full character, just put 5 sprites together, and add them to the same group. Then, use “Add a force to CharacterGroup” to make them move as a whole.

For the save/load, you will need a xml file, where you will store your variables.
For the character, it would be CharacterHead, to store the number of animation for the sprite of the head. CharacterLeftArm for the animation number of the sprite LeftArm, etc.

This is very true :smiley:
It really makes sense,more than enough to choose from 3 common settings that should fit anybody needs. :slight_smile:

Great idea this could work,thanks.You helped a lot :slight_smile: