Quote:
Originally posted by happy
Hello,
I wanted to create some code that would take away control from the player for a while and then give it back to him/her, and started off using
This does indeed take control from the player, but the camera seems to jump back to the top-left corner of the map! Do I need to dick about with the cameratracker and cameratracking vars to avoid this?
Also, I had a go making a WaitForEntity() function and came up with this... is there a better way to do this?
void WaitForEntity(int ent, string script)
{
TogglePlayerControl(0);
MoveEntity(ent, script);
while(entity.movecode[ent] == 3)
{
Render();
ShowPage();
}
TogglePlayerControl(1);
}
Thanks for your time, guys!
Yep, set cameratracking to 0 to allow user control of the camera (that is, it won't change unless you alter xwin/ywin), cameratracking to 1 when you're following the player, cameratracking to 2 when you're following cameratracker (an entity index). That make
int player = EntitySpawn(blah blah);
void TogglePlayerControl(int on)
{
if(on)
{
cameratracking = 1;
SetPlayer(player);
}
else
{
cameratracking = 0;
SetPlayer(-1);
}
}
Also, if your WaitForEntity thing works, it's probably a good way to do it. I've been wondering about how to make scripts pause for non-player entity movements (PlayerMove() does Render()/ShowPage() until the animation finishes). I was sort timing animations as they went along and had a Wait() function that would specify a delay directly after EntityMove(). Your idea's way better though. Although... I don't think you need to toggle the player control, since the player entity controls are only processed when there's no VC functions active.