Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (AndrewAMD, bigsmack, 7th_zorro, dr_panther), 1,364 guests, and 7 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
ent_remove in event wont works #438281
03/11/14 15:32
03/11/14 15:32
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
hey guys, Simon again:

i have a Problem with removing a sprite entity in its own Action:
Code:
void act_some();
void ev_event();

void main(){
 
    you = ent_create("file.tga", nullvector, act_some);
    your.skill1 = "something";
}

void act_some(){

    my.emask = ENABLE_SCAN;
    my.event = ev_event;
}

void ev_event(){

    if(Event_type == EVENT_SCAN)
        ent_remove(me);
}

//just a part of my code - the true one is bigger



game starts, works fine, until the ent_remove then scknex engine says: "Invalid call in Event ev_event".

thanksfor your help! :-)

answers could also be in Germany (would be better)

Last edited by Simon_Schwitzky; 03/11/14 15:33.

Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: ent_remove in event wont works [Re: Simon_Schwitzky] #438284
03/11/14 16:29
03/11/14 16:29
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Perhaps you're removing the entity more than once after the frame you are trying to delete it from, which is impossible.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: ent_remove in event wont works [Re: DLively] #438285
03/11/14 16:30
03/11/14 16:30
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
generally, (And I am just migrating from c_script) I would do something to likes of:

action thisact{

while(my.health>0){wait(1);}
ent_remove(me);

}


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: ent_remove in event wont works [Re: DLively] #438288
03/11/14 16:49
03/11/14 16:49
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
thank you for the reply:

i don't really understand your first post.

and to the second:

i tried it to put an wait(-5) after the ent_remove, same fail.
i Need this scan Event, so i can't put it into the Action...


Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: ent_remove in event wont works [Re: Simon_Schwitzky] #438290
03/11/14 17:20
03/11/14 17:20
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
ent_remove should ALWAYS be the LAST FUNCTION played by your event. wink


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: ent_remove in event wont works [Re: DLively] #438292
03/11/14 17:24
03/11/14 17:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Reason and solution are already in the manual (excuse the German quote):

Quote:
Die Eventfunktion selbst sollte einfach sein. Normalerweise sollte sie keine Informationen an die Main-Funktion der Entity übermitteln - sie sollte keine Anweisungen ausführen, die wiederum selbst Events auslösen, Entities verschieben oder sonst irgendetwas im Level verändern können. Anweisungen wie c_move, ent_create, ptr_remove, c_trace etc. dürfen also nicht durchgeführt werden. Sollte dies nämlich der Fall sein, können alle möglichen unschönen Dinge passieren: etwa dass zwei Entities bis ins Unendliche gegenseitg ihren Event auslösen (in diesem Falle würde das Game einfrieren). Muß die Eventfunktion aus irgendeinem Grund solche 'kritischen Anweisungen' durchführen, müssen diesen, um sie aufs nächste Frame hin zu verzögern ein wait(1) vorangestellt sein, dann ist es sicher.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: ent_remove in event wont works [Re: DLively] #438294
03/11/14 17:26
03/11/14 17:26
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
OH MY GOD!

thank you very much, it works now perfectly!
I'm so glad you helped me!

but one more question: why can't i remove the entity in a Action?


Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: ent_remove in event wont works [Re: DLively] #438295
03/11/14 17:27
03/11/14 17:27
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: DevoN
ent_remove should ALWAYS be the LAST FUNCTION played by your event. wink

ent_remove SHOULD NOT AT ALL be called in an event!
Originally Posted By: The holy manual
Event functions are actually executed during the engine function that caused the event, like a c_move, c_scan, or c_trace instruction of another entity. The event function itself should be simple. It normally should only transfer information to the entities' main function - it shouldn't perform instructions that can trigger events itself, displace entities, or change anything else in the level. Thus instructions like c_move, ent_create, ent_remove, c_trace etc. must not be performed


Always learn from history, to be sure you make the same mistakes again...
Re: ent_remove in event wont works [Re: Uhrwerk] #438299
03/11/14 17:36
03/11/14 17:36
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
Ok thank you, I did'nt find that.
Now I know how to use somwthing like this!:-)


Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: ent_remove in event wont works [Re: Uhrwerk] #438301
03/11/14 17:38
03/11/14 17:38
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
If you want to use a loop for your entity the following pattern has proven to work just fine for me:

Code:
void my_event()
{
	if(...) my.skill20 = 0;
}

action my_action()
{
	...
	my.skill20 = 1;
	while(my.skill20)
	{
		do sth;
		wait(1);
	}
	ptr_remove(me);
}



All code which is more complex than setting a few values should be delegated to your main loop like that.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
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