Hi
For some reason my player character is not releasing an animation view and returning to the view he was before the object interaction. If you walk between clicks (have coded for 5+ clicks) it shows animation view even though I have used cFrankj.UnlockView();!
There appears to be a few issues with LockView I believe?
There are 2 possible views for player before the interaction with object which after interacting need to return to the view before the interaction:
View 8: Normal
View 17: has foot sawn off
Mouse Click 5:
}
else if (key_clicks ==5) { // key clicks
cFrankj.Say("I'll make one final attempt!");
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
Display("You manage to grab the key.");
object[16].Visible=false;
cFrankj.AddInventory(iKey);
cFrankj.FaceLocation(185,170);
object[12].SetView(19, 0, 0);
object[12].Animate(0, 3, eRepeat, eNoBlock);
cbjorn.Say("I'm so glad you sacrificed your fingers to get the Key. That shows promise.
The Key fits the lock of a metal box in the right hand corner of the room. Open it.");
object[12].SetView(20, 0, 0);
}
Hope this is understandable and you can see where I may have ****** up
cheers
barefoot
Hi
This appears to work for the Normal view interaction with object.. I need now to apply it for the Leg sawn off View. Would I need to replicate the code and change player.View==17?
function obrickblade_Interact()
{
key_clicks++;
if (player.View==8){
if (key_clicks ==1)
{
object[21].Visible=true;
object[21].SetView(24);
cFrankj.ChangeView(26);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[22].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
cFrankj.ChangeView(8);
}
else if (player.View==8 && key_clicks ==2){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.ChangeView(26);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[24].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
cFrankj.ChangeView(8);
}
else if (player.View==8 && key_clicks ==3){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.ChangeView(26);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[25].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
cFrankj.ChangeView(8);
}
else if (player.View==8 && key_clicks ==4){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.ChangeView(26);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[26].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
cFrankj.ChangeView(8);
}
else if (player.View==8 && key_clicks ==5){
cFrankj.Say("I'll make one final attempt!");
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
Display("You manage to grab the key.");
object[16].Visible=false;
cFrankj.AddInventory(iKey);
cFrankj.FaceLocation(185,170);
object[12].SetView(19, 0, 0);
object[12].Animate(0, 3, eRepeat, eNoBlock);
cbjorn.Say("I'm so glad you sacrificed your fingers to get the Key. That shows promise. The Key fits the lock of a metal box in the right hand corner of the room. Open it.");
object[12].SetView(20, 0, 0);
}
}
}
Please let me know if you spot anything yuk.
barefoot
Hi
found the problem and the solution. I was changing to animation view before the LockView... And also changing player views during..
So now I have this code and it appears to run ok for whatever view you are before interacting with object.. Works up to now, fingers crossed..
function obrickblade_Interact()
{
key_clicks++;
if (key_clicks ==1)
{
object[21].Visible=true;
object[21].SetView(24);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[22].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
}
else if (key_clicks ==2){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[24].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
}
else if (key_clicks ==3){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[25].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
}
else if (key_clicks ==4){
object[21].Visible=true;
object[21].SetView(24);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[26].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
}
else if (key_clicks ==5){
cFrankj.Say("I'll make one final attempt!");
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
Display("You manage to grab the key.");
object[16].Visible=false;
cFrankj.AddInventory(iKey);
cFrankj.FaceLocation(185,170);
object[12].SetView(19, 0, 0);
object[12].Animate(0, 3, eRepeat, eNoBlock);
cbjorn.Say("I'm so glad you sacrificed your fingers to get the Key. That shows promise. The Key fits the lock of a metal box in the right hand corner of the room. Open it.");
object[12].SetView(20, 0, 0);
}
}
Hopefully my Perseverance has now paid off.
barefoot
I've cleaned that up for you:
function obrickblade_Interact()
{
key_clicks++;
if (key_clicks < 5)
{
object[21].Visible=true;
object[21].SetView(24);
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[21].Animate(0, 2, eOnce, eBlock, eForwards);
object[22].Visible=true;
object[27].Visible=true;
cFrankj.FaceLocation(75, 125);
cFrankj.Say("Aghhhhhhhhh!! It's chopped a finger off!!");
object[21].Visible=false;
}
else if (key_clicks ==5)
{
cFrankj.Say("I'll make one final attempt!");
cFrankj.LockView(26);
cFrankj.Animate(0, 9, eOnce, eBlock, eForwards);
cFrankj.UnlockView();
Display("You manage to grab the key.");
object[16].Visible=false;
cFrankj.AddInventory(iKey);
cFrankj.FaceLocation(185,170);
object[12].SetView(19, 0, 0);
object[12].Animate(0, 3, eRepeat, eNoBlock);
cbjorn.Say("I'm so glad you sacrificed your fingers to get the Key. That shows promise. The Key fits the lock of a metal box in the right hand corner of the room. Open it.");
object[12].SetView(20, 0, 0);
}
else {
Display("There's nothing to do with that anymore.");
}
}
Since this is a room script, you can use the actual scriptnames when addressing objects, no need for object[12] and the like, makes the code a lot more readable.
But, ah, the random indentation and putting an identical block of code four times in there? Wow.
I don't mean to be rude but haven't you been doing this for months now?
What's so hard about this?
Hi Khris
thanks for your comments and accepted duly.
I need if (key_clicks ==1) and else if (key_clicks ==2) etc etc because each click makes an object appear (finger) so can't use (key_clicks < 5) if I want each finger to appear after each click..
That is why I have used repeated code for each finger object to appear..
I did not find it really hard but it was time consuming getting it just right..
Thanks Khris
barefoot
Granted, I missed that, but you can swap objects 22 and 23, then use
object[22 + key_clicks].Visible=true;
It's the only line that differs and it uses a value that increments by one, just like key_clicks. I doesn't get more straightforward than that.
And even if there were more differences, and more complicated ones, you'd put the block in a function, then use parameters for the stuff that differs each time.
There's no excuse for having the same code over and over again. None.
Hi Khris
Didn't realise that.. Iv'e added it to my script files.
And yes, I have been reg for quite some time.. But only about 20 months at home.
Cheers
barefoot