Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
When i remov entity, it is not disappearing #212066
06/20/08 04:23
06/20/08 04:23
Joined: Jun 2008
Posts: 21
L
lakshya Offline OP
Newbie
lakshya  Offline OP
Newbie
L

Joined: Jun 2008
Posts: 21
Hi,

In my game i remove my entity in the action event
so code look like

action bla() {
while(1) {
....
.......
ent_remove(Resource);
.....
...
}
}

but it is not removing entity from my game( It still visible in my game).
so first time code run ok, but due to while loop when it is executing next time then it show error " Invalid Argument - Entity ".


Thanks in Advance

Re: When i remov entity, it is not disappearing [Re: lakshya] #212068
06/20/08 04:38
06/20/08 04:38
Joined: Apr 2007
Posts: 582
Germany
Poison Offline
User
Poison  Offline
User

Joined: Apr 2007
Posts: 582
Germany
You should´t use ent_remove in a while loop....because after removing the entity the Poiter becomes empty an than the engine shows you this funny error :P

use something like this:
Code:
 
function bla()// you can use action
{
my.skill1 = 100;
while(my.skill1 > 0)
{
//....the code
if(my life is down and I die)//<-----xD just put something in to stop the loop
{
my.skill1 = 0;
}
wait(1);
}
ent_remove(resource);
}



Everything is possible, just Do it!
Re: When i remov entity, it is not disappearing [Re: Poison] #212069
06/20/08 04:45
06/20/08 04:45
Joined: Jun 2008
Posts: 21
L
lakshya Offline OP
Newbie
lakshya  Offline OP
Newbie
L

Joined: Jun 2008
Posts: 21
yeh, i know this
but actually i have to collect resource, so i check player collision with resources through c_move function. And i have to write code for player movement in while loop.
so in while loop i check if distance is <=0 then collision occur(means got resources)so i delete that resources.

So can you tell me another way.

Actually i am new in Lite-C programing. so if we can write any another way of collecting resource code then also its good.

Thanks



in

Re: When i remov entity, it is not disappearing [Re: lakshya] #212087
06/20/08 09:56
06/20/08 09:56
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
while(my != NULL)
...
you = resource;
ent_remove(you);


Last edited by flits; 06/20/08 09:56.

"empty"
Re: When i remov entity, it is not disappearing [Re: flits] #212179
06/20/08 19:09
06/20/08 19:09
Joined: Jun 2008
Posts: 21
L
lakshya Offline OP
Newbie
lakshya  Offline OP
Newbie
L

Joined: Jun 2008
Posts: 21
Thanks for your help, but it shouldn't help me
Actually i am stuck with one problem

I want to write code about collect resource, and in this i wrote code in my player action event
i moved my player with c_move()
so at that time i check if distance is <= 0, then collision occur so i call collect resource function.

here senario is like this



collectResource()
{
....
...
if(me==Enemy) {
//ent_remove(Enemy);
}
if(me==Resource) {
......
......

}
if(me==Hero) {
//ent_remove(Resource);
Resource.flags &= ~VISIBLE;
//Resource=null;

wait(3);
game_score+=10;


}




action myHero()
{
Hero=me;
my.skill1=1;
....

.....
while(1)
{
....
....
....
distance=c_move(me, ,,, , ,, , GLIDE);
if(distance <=0) { collectResource(); }
......

.....
}


function main()
{
...
...
ent_create("hero.mdl", ... ,myHero);

}


So here After collecting resource i delete that entity and increase score board, but this code in while(1) loop
so every time it pop up error about ENTITY

I am new in Lite-C, so i don't know much.

Please help me

Thanks

Re: When i remov entity, it is not disappearing [Re: lakshya] #212305
06/21/08 14:06
06/21/08 14:06
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
So, if I understand correctly, your Hero collects resource when he gets stuck, and when the 'me' is an Enemy, Resource or Hero it should do something (Isn't 'me' always the Hero?). When 'me' is the Hero the entity that is the Resource should be removed, right?

So everytime Hero gets blocked the resources should be removed. However, if they are removed once they cannot be removed again, so there is already a flaw in your script. I don't know who 'Resource' is, but I take it that there is only one resource then, and no walls?

I think you need to throw this away and rewrite it. You better use something else than c_move to see if you collided with a resource entity:

from player -> c_scan (good solution)
from player -> linkedlist or array of all resources -> loop through all resources -> vec_dist (good solution)
from individual resources -> vec_dist (average to good solution)
ent_next -> vec_dist (bad solution)

The method to use depends on the context of your "model". I think that an array of resources that you loop through and check the vec_dist between resource and player would be easy enough to implement and would work well.

You can try c_scan too, but I personally don't like that function, makes me feel I am not in control of what happens smile. Take whatever suits you.


Click and join the 3dgs irc community!
Room: #3dgs
Re: When i remov entity, it is not disappearing [Re: Joozey] #212336
06/21/08 16:30
06/21/08 16:30
Joined: Jun 2008
Posts: 21
L
lakshya Offline OP
Newbie
lakshya  Offline OP
Newbie
L

Joined: Jun 2008
Posts: 21
hi i am new in lite-c programing
so i not understand what you saying
sorry about that
can you please write down that code for me

Thank you

Re: When i remov entity, it is not disappearing [Re: lakshya] #212340
06/21/08 16:57
06/21/08 16:57
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
it's not a code, those are just some options you can choose, and all can be used in c-script as well.

from player -> c_scan
in the player function you can use c_scan to scan for surrounding entities. You just check if the scanned entities are classified by you as resource or not.

from player -> array of all resources -> loop through all resources
use an array to store all the resource entities in your level, and in the player function walk through the whole array to check the distance between player and resource entity.

rom individual resources -> vec_dist
in the resource entity function, use vec_dist from 'me' to the player to check the distance.

ent_next -> vec_dist
In the player function, loop through all the entities in the entire level and check if they are classified by you as a resource. Then perform vec_dist between current entity and player to determine distance.



Last edited by Joozey; 06/21/08 16:58.

Click and join the 3dgs irc community!
Room: #3dgs

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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