Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Problem with Remove #93612
10/08/06 14:02
10/08/06 14:02
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
Nevermind my original problem. I found out that it needed to be ent_remove, not just remove.
However, I get no errors but the code doesnt do what its supposed to. I suppose its not loopign right but I dont know why...
Heres the code.
Code:
 
var vec_dist_var=0;
var player_vector[3];

action vec_dist_test
{
while(1)
{
player_vector.x=my.x;
player_vector.y=my.y;
player_vector.z=my.z;
wait(1);
vec_dist_var=vec_length(player_vector);
wait(1);
IF(vec_dist_var>=100)
{
ent_remove(me);
return;
}
wait(1);
}
}



I put in numbers... and itll appear if its over 70, because thats how far the player is from the object, however, it I move away from it it stays like its not suuposed to. Any help?

Last edited by Towelie; 10/08/06 14:08.

Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Re: Problem with Remove [Re: Towelie] #93613
10/08/06 14:15
10/08/06 14:15
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Never (!) run ent_remove() from within:
- a while(1) loop
- an event function

Use this:
Code:

var vec_dist_var=0;
var player_vector[3];

action vec_dist_test
{
while(!my.skill20)
{
vec_set(player_vector.x,my.x);
wait(1);
vec_dist_var=vec_length(player_vector);
IF(vec_dist_var>=100) { my.skill20 = 1; }
wait(1);
}
wait(1);
ent_remove(me);
}



Uhm but what exactly want you the code to do?
Sorry didn't understand what you said in your first post.

Last edited by Thunder; 10/08/06 14:16.
Re: Problem with Remove [Re: Xarthor] #93614
10/08/06 14:18
10/08/06 14:18
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
I wanted the code to
1) Check how far from the player an object is (the object holding the action vec_dist_test)
2)If the player goes over 300 units from the object, the object gets removed.

Your code wouldn't work then would it? The ent_remove is outside the if function.

Last edited by Towelie; 10/08/06 14:19.

Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Re: Problem with Remove [Re: Towelie] #93615
10/08/06 14:20
10/08/06 14:20
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Ok why not use this:
Code:

define distance,skill1;
define max_dist,skill2;
define kill_skill,skill3;

action dist_object
{
my.max_dist = 300;

// wait until the player was created:
while(!player) { wait(1); }

//while my.kill_skill == 0 ..
while(!my.kill_skill)
{
//store the distance in a skill
my.distance = vec_dist(my.x,player.x);

//compare
if(my.distance > my.max_dist)
{ my.kill_skill = 1; } //its bigger so kill the while
}
//wait a frame
wait(1);
//remove me:
ent_remove(me);
}

undef distance;
undef max_dist;
undef kill_skill;



Edit:
my code will work, caus it uses a boolean var (the kill_skill) as condition for the while loop.
So if you set the kill_skill to non-zero the while loop will be "killed" and the entity proceeds with the code which comes after the while loop.
So it waits one frame (safety reasons), and then removes itself.

Last edited by Thunder; 10/08/06 14:25.
Re: Problem with Remove [Re: Xarthor] #93616
10/08/06 14:30
10/08/06 14:30
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
Hmm, a few things:
1) That looks like a foreign language... which it still is so far. I've been scripting for about a week, and its mostly been not very advanced stuff with buttloads of errors I've worked out.
2) The code itself, the one you gave me, didn't work. I set it to as low as 1 and it didn't remove the entity.

Thanks for the help so far!


Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Re: Problem with Remove [Re: Towelie] #93617
10/08/06 14:37
10/08/06 14:37
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
It might not get removed because you have no entity which has the player pointer set to it.

Are you using the templates?

btw: that is no foreign language but c-script

Edit:
Ok I changed the code slightly.
It now checks the distance to the camera and not to the player entity:
Code:

define distance,skill1;
define max_dist,skill2;
define kill_skill,skill3;

action dist_object
{
my.max_dist = 300;
my.kill_skill = 0;

//while my.kill_skill == 0 ..
while(!my.kill_skill)
{
//store the distance in a skill
my.distance = vec_dist(my.x,camera.x);

//compare
if(my.distance > my.max_dist)
{ my.kill_skill = 1; } //its bigger so kill the while
}
//wait a frame
wait(1);
//remove me:
ent_remove(me);
}

undef distance;
undef max_dist;
undef kill_skill;



Last edited by Thunder; 10/08/06 14:41.
Re: Problem with Remove [Re: Xarthor] #93618
10/08/06 14:41
10/08/06 14:41
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
Now that I take a closer look at it...
Should my.x, my.y and my.z beplayer.x, player.y and player.z?
I tried this and I come up with an empty pointer for each one over and over again.
I'm using the a6 walkthrough template for my player action, because I cannot write my own yet.
However, the script you are looking at is in a separate file (I included it)


Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Re: Problem with Remove [Re: Towelie] #93619
10/08/06 17:06
10/08/06 17:06
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
Ok well I went back a step and tested something simpler. Again, I am gettign a constant empty poitner error.
New code:
Code:

var vec_dist_var=0;
var player_vector[3];
var vec_varx=0;

action vec_check
{
while(1);
{
vec_varx=vec_dist(my.x,player.x);
wait(1);
if(vec_varx<=100)
{
ent_remove(me);
return;
}
wait(1);
}

}

action vec_dist_test
{
while(1)
{
player_vector.x=player.x;
player_vector.y=player.y;
player_vector.z=player.z;
wait(1);
vec_dist_var=vec_length(player_vector);
wait(1);
IF(vec_dist_var>=100)
{
ent_remove(me);
return;
}
wait(1);
}
}



The top action is the new action while the bottom action is the original problem to this thread.


Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Re: Problem with Remove [Re: Towelie] #93620
10/08/06 17:26
10/08/06 17:26
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Add the following while loop BEFORE your while(1) loop:
while(!player) { wait(1); }
This will wait until the player pointer gets non-zero.
So it prevents any empty pointer message.
However I think the player pointer will no be set at all, so try out the edited code from me above, which works with the camera position.

Another thing:
Instead of writing:
vector.x = bla.x
.y = .y
and so on, you can simply write:
vec_set(player_vector.x,player.x);
This does exactly the same as your 3 lines in the action "vec_dist_test"

However there is no need to store this, caus you can also pass entity parameters (such as positions, skills) to a engine function.

Next thing is:
vec_length does not return the distance of your player to the object, but the distance to the level origin.

And:
As I said do NOT remove an entity from within its while loop.
Instead use a skill (set to zero) as a condition for the while loop.
so: while(!my.skill20) will run as long as my.skill20 == 0
Set skill20 to non-zero and the while loop will be aborted and the action will continue with the stuff which comes behind the while loop.
Take a close look at my example thats exactly what I'm doing.

Re: Problem with Remove [Re: Xarthor] #93621
10/08/06 19:14
10/08/06 19:14
Joined: Feb 2005
Posts: 1,785
Jesusland
Towelie Offline OP
Serious User
Towelie  Offline OP
Serious User

Joined: Feb 2005
Posts: 1,785
Jesusland
But I'm not that advanced, I dont even know how to use skills in that way yet.
I'm using Kinji's Noob Way manual, which was designed for a5. I know this is the source of many problems, but stuff like this should be the same no?


Jimmy died, today, he blew his brains out into the bay, in the state of mind, its my own private suicide. A stitch in time saves nine... what the hell does that mean?!?
Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1