GML Object is not moving[SOLVED]

Enreeper

Member
i have written a code that let you choose how fast it is and in wich direction it goes, but the object wont move.

here´s my code

obj_WallMoving

MiddleMouseRealesed:

move_direction=get_string("Type in the direction","")
move_speed=get_string("Type in the speed","")

Step:

///check if level is started
if global.playmode=1
{

if move_direction=("move_left")
{
direction=+45
speed=("move_speed");
}

}
 

Jonar

Member
Do you mean that you can't type in the speeds or that the object won't move after you type them in?
 

Enreeper

Member
Do you mean that you can't type in the speeds or that the object won't move after you type them in?
When im in game and click on the object, the strings works fine, but when i set global.playmode to 1 the object wont move
 
speed=("move_speed");
You are trying to set a number variable (speed) to a string "move_speed". You are not reading the variable called move_speed, you are actually trying to convert the text "move_speed" into a number, which will not work (or it will just convert to 0). Try actually setting the speed variable to the variable move_speed. What you currently have is like the "Hello World" bit of this page: http://docs2.yoyogames.com/index.ht..._reference/type_actions/string_to_number.html
Try just doing the following:
Code:
speed=move_speed;
and see if that accepts what you have entered as a number to start with. If it doesn't accept it then you will have to convert the text you have entered into a number like this:
Code:
code =real(move_speed);
For more info on converting a string to a real look here: http://docs2.yoyogames.com/index.ht...3_scripting/4_gml_reference/strings/real.html
 

Enreeper

Member
You are trying to set a number variable (speed) to a string "move_speed". You are not reading the variable called move_speed, you are actually trying to convert the text "move_speed" into a number, which will not work (or it will just convert to 0). Try actually setting the speed variable to the variable move_speed. What you currently have is like the "Hello World" bit of this page: http://docs2.yoyogames.com/index.html?page=source/_build/3_scripting/2_drag_and_drop_reference/type_actions/string_to_number.html
Try just doing the following:
Code:
speed=move_speed;
and see if that accepts what you have entered as a number to start with. If it doesn't accept it then you will have to convert the text you have entered into a number like this:
Code:
code =real(move_speed);
For more info on converting a string to a real look here: http://docs2.yoyogames.com/index.html?page=source/_build/3_scripting/4_gml_reference/strings/real.html

OMG It work´s !, thx
 
Top