Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: Rocco on September 09, 2004, 03:46:40 PM
-
i cant get this script to work:
http://forum.dead-code.org/index.php?topic=615.0
i have
SCRIPT="scripts\direct_control.script"
in the default.game script
and the direct_control.script in the scripts folder, with updated actor:
actor.PlayAnimAsync("actors\Dave\ll\walk.sprite");
break;
but nothing happens, when i use the keys
-
i have
SCRIPT="scripts\direct_control.script"
in the default.game script
Did you attach the script in ProjectMan or did you edit the default.game file by hand? It's not a good idea to edit ths file directly if the project is open in ProjectMan, because all changes will be overwritten.
I tried to create a new project, copied the direct_control.script to scripts folder, attached in ProjectMan and it works ok, so I suspect it's the above case..? I can upload the project if needed.
-
I attached the file, without edit the default.game script by hand, cause i realized that theres no way to save the changes.
I made a test file: http://www.virtual-illusion.com/test.zip
im new to wme so i guess its a mistake cause i dont understand exactly, how the scripts fit together right now.
thanks for helping
-
The problem is in the movement.script. You probably forgot to copy the CanMoveThere function from the original thread.
The entire movement.script should look like this:
#include "scripts\base.inc"
#include "scripts\keys.inc"
var TargetX, TargetY;
var LastDir = -1;
var CurrentDir = -1;
while(true)
{
// get a requested direction depending on pressed-down keys
if (Keyboard.IsKeyDown(VK_LEFT) && Keyboard.IsKeyDown(VK_UP)) CurrentDir = DI_UPLEFT;
else if(Keyboard.IsKeyDown(VK_LEFT) && Keyboard.IsKeyDown(VK_DOWN)) CurrentDir = DI_DOWNLEFT;
else if(Keyboard.IsKeyDown(VK_RIGHT) && Keyboard.IsKeyDown(VK_UP)) CurrentDir = DI_UPRIGHT;
else if(Keyboard.IsKeyDown(VK_RIGHT) && Keyboard.IsKeyDown(VK_DOWN)) CurrentDir = DI_DOWNRIGHT;
else if(Keyboard.IsKeyDown(VK_LEFT)) CurrentDir = DI_LEFT;
else if(Keyboard.IsKeyDown(VK_RIGHT)) CurrentDir = DI_RIGHT;
else if(Keyboard.IsKeyDown(VK_UP)) CurrentDir = DI_UP;
else if(Keyboard.IsKeyDown(VK_DOWN)) CurrentDir = DI_DOWN;
else CurrentDir = -1;
if(CurrentDir==LastDir)
{
// check for blocked areas
if(!CanMoveThere(CurrentDir)) actor.Reset();
}
else
{
// start walking
if(CurrentDir==-1 || !CanMoveThere(CurrentDir)) actor.Reset();
else
{
actor.TurnTo(CurrentDir);
switch(CurrentDir)
{
case DI_LEFT:
actor.PlayAnimAsync("actors\molly\ll\walk.sprite");
break;
case DI_RIGHT:
actor.PlayAnimAsync("actors\molly\rr\walk.sprite");
break;
case DI_UP:
actor.PlayAnimAsync("actors\molly\uu\walk.sprite");
break;
case DI_DOWN:
actor.PlayAnimAsync("actors\molly\dd\walk.sprite");
break;
case DI_UPRIGHT:
actor.PlayAnimAsync("actors\molly\ur\walk.sprite");
break;
case DI_UPLEFT:
actor.PlayAnimAsync("actors\molly\ul\walk.sprite");
break;
case DI_DOWNRIGHT:
actor.PlayAnimAsync("actors\molly\dr\walk.sprite");
break;
case DI_DOWNLEFT:
actor.PlayAnimAsync("actors\molly\dl\walk.sprite");
break;
}
}
}
LastDir = CurrentDir;
Sleep(20);
}
function CanMoveThere(Direction)
{
var CanMove = true;
switch(Direction)
{
case DI_LEFT:
if(!Scene.IsWalkableAt(actor.X-15,actor.Y)) CanMove = false;
break;
case DI_RIGHT:
if(!Scene.IsWalkableAt(actor.X+15,actor.Y)) CanMove = false;
break;
case DI_UP:
if(!Scene.IsWalkableAt(actor.X,actor.Y-15)) CanMove = false;
break;
case DI_DOWN:
if(!Scene.IsWalkableAt(actor.X,actor.Y+15)) CanMove = false;
break;
case DI_UPRIGHT:
if(!Scene.IsWalkableAt(actor.X+15,actor.Y-15)) CanMove = false;
break;
case DI_UPLEFT:
if(!Scene.IsWalkableAt(actor.X-15,actor.Y-15)) CanMove = false;
break;
case DI_DOWNRIGHT:
if(!Scene.IsWalkableAt(actor.X+15,actor.Y+15)) CanMove = false;
break;
case DI_DOWNLEFT:
if(!Scene.IsWalkableAt(actor.X-15,actor.Y+15)) CanMove = false;
break;
}
return CanMove;
}
You were missing the last part.
If there is some problem with your game, always check the wme.log file in your project folder. It logs any runtime errors which is often very useful.
-
big thanks, it works fine
im a sleepy head today.
-
ok i do it for the 3d character but only sty in the place and make some rotation...don´t move foward...
any help for 3dcharacter to move with keys..
thanks
MArtin
-
ok i do it for the 3d character but only sty in the place and make some rotation...don´t move foward...
any help for 3dcharacter to move with keys..
thanks
MArtin
As I said in the other thread (http://forum.dead-code.org/index.php?topic=744.msg5788#msg5788), there will be better scripting support for keyboard control for 3D characters in the next WME build. It's already implemented, please wait a few days for the next release. Thanks.
-
ok well i will be waiting that
thanks
MArtin