Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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 (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Random Entity appearance #137726
06/23/07 11:57
06/23/07 11:57
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
Hi
I have a little problem:
I have an entity which can be be killed by the player and i want only one of this entity in my level, but when it's killed it should appear randomized in an other part of the level.so simply the entity should disappear when you hit it and then it should appear on an other position in the level.
i also wrote a little code for this but it doesn't work....

var anz = 1; //to check that theres only one entity

action entity
{
...
// after hitting the entity
anz = 0;
ent_remove(me);
}


var x;
var y;
var z;

function entity_creating()
{
while (!player)
{
if (anz < 1)
{
x = int(random(580) -290);
y = int(random(424) -212);
z = 32;
vec_set (temp,vector(x,y,z));
ent_create (gem_mdl,temp,entity);
}
wait(1);
}
}

Could someone please help me?


mfg Disaster
Re: Random Entity appearance [Re: Disaster] #137727
06/23/07 12:35
06/23/07 12:35
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
There is a mistake in your code:
x = int(random(580) -290);
y = int(random(424) -212);
z = 32;

x,y,z are reserved names and should not be used for naming your var.
replace thoses lines by:
temp.x = int(random(580) -290);
temp.y = int(random(424) -212);
temp.z = 32;

and delete the line "vec_set()" as you do not need it anymore.

EDIT:
Further more your while loop statement is wrong.
That while loop while run as long as player is NOT true.
Change it into this:
while(!player) { wait(1); }
while(player)
{
//your spawn code
}

Last edited by Xarthor; 06/23/07 12:36.
Re: Random Entity appearance [Re: Xarthor] #137728
06/23/07 14:24
06/23/07 14:24
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
thank you^^ no the code works


mfg Disaster

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