I need to speed up my script because when
I set object speed too high the script does not
'see' the collision that it's supposed to detect.
Is there a way to speed this up? If you have
alternate solutions to collision detection feel
free to say :) . I don't wish to use the collision
detection plugin because the game gains +0.5Mb
SSH, you did show me your script but I didn't get it.
(I'm just a begginer). What is || in script?
Oh, and here's my script:
Global script
function displaynice() {
int true,playerx,objectx;
playerx=character[A].x;
objectx=GetObjectX(0);
if (playerx==objectx) // can I here do this: (character[A].x==GetObje...)
{
true=1;
}
return true; //returns 1 if the characters are colliding but only if object speed is 3 or less
}
When character intracts with inventory to this character
(EGO throws object at A)
StopMoving (A);
SetCharacterView (EGO,2); //throwing view
Wait(40);
AnimateCharacter (EGO, 0, 3, 0); //throwing animation
Wait(20);
ObjectOn(0); //object becomes visible
MoveObjectDirect(0,350,160,1); //object flying trough the air
Room Repeatedly execute
if (displaynice()==1){ // if they are collided...
SetCharacterView (A, 4); // ...death view....
AnimateCharacter (A, 0, 5, 0); // ...death animation....
while(character[A].animating) Wait(1);
SetGlobalInt(1,1); //It's dead. Blimey! needed for something else
SetCharacterView (EGO,1); // back to normal view
RestoreWalkableArea (1); // the player can walk again
}
Can this "(playerx==objectx)" be changed with
"(character[A].x==GetObjectX(0)"
----
I've just got it. I was REALLY REALLY dumb.
thanks ppl
What is || in script?
That means "OR" it is an operator
Here, check here, go into your manual. Select the tab that says "Contents", then open the subfolder with "text scripting", then select "scripting tutorial part 2" and then read
1. Try using AreCharObjColliding (CHARID, int obj) instead of displaynic(..).
2. When you declare variables you are not guaranteed that they will be set to any particular value. You have assumed that true would be set to a value of zero.
Quotefunction displaynice() {
int true,playerx,objectx;
3. You scare me man :). Don't be changing the value of variables named true or false, it's considered to be bad programming practice.
Quotetrue=1;
Instead just do this: int true=1; or Use another variable name such as "status" if you want to change the value during program execution.
4. Yes.
Quote
if (playerx==objectx) // can I here do this: (character[A].x==GetObje...)
You don't need to speed it up. The script doesn't catch collision event because at higher speeds object's co-ordinates are changed more "jerky" so it's most likely it goes at playerx+1 co-ordinate or so, for example, but not at playerx exactly. Therefore what you need is to use the code SSH had offered. Replace your displaynice() function with his variant instead.
-Cheers