Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
question about ent_create #128878
05/09/07 14:05
05/09/07 14:05
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i want to create a player ship without haveing to put it in a level and assigning an action to it so i figured useing ent_create would be the way to go, the reason for this is because when you switch camera views from isometric view (exterior) to fps view (interior)you`ll go from seeing your ship to being on the bridge of the ship. to do this i`ll need to be able to make the ship invisible and ent_create the bridge, then purge the ship mesh. and vice versa of course. so i figure at the start i`ll ent_create the ship, then allow players to switch between views. so i did this to try it out.

Code:

function main()
{
level_load("darkfrontiers.wmb");
mouse_map = hempire_pcx;
mouse_mode = 1;
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (1);
}
wait (3);
ent_create (galor_mdl, vector(0, 0, 0), c_ship);

}


however no ship appears at those coordinates, however it may be a case of the camera view not starting up which is why i`m a bit confused. the c_ship function works as an assigned action, the ship is there (naturly lol as it was added in wed) but as a function maybe it won`t. the function code is below and thanks in advance for any advice.
Code:

function c_ship
{
player = my;
my.scale_x = 2.0;//scale it down to have it's size
my.scale_y = my.scale_x;//same as scale x
my.scale_z = my.scale_x;//same as scale x
var ship_speed;
while (1)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 1.3 * time;
}
}
else
{
if (ship_speed.x >= 0)
{
ship_speed.x -= 0.05 * time;
}
}
if (ship_speed.x < 0) {ship_speed.x = 0;}
if (key_a == on)
{
my.pan += 3 * time;
my.roll - = 3 * time;
}
if (key_d == on)
{
my.pan -= 3 * time;
my.roll + = 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_q == on)
{
my.tilt + = 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_e == on)
{
my.tilt - = 3 * time;
}
ent_move (ship_speed.x, nullvector);
ship_camera();
wait (1);

}
}




Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: question about ent_create [Re: jigalypuff] #128879
05/09/07 14:16
05/09/07 14:16
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
there is an endless loop in your main function, so the ent_create line will never be reached

Re: question about ent_create [Re: jigalypuff] #128880
05/09/07 14:16
05/09/07 14:16
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
or maybe easyer will be use camera.genius = player? and put inside camera at the nose of ship by vec_for_vertex?
or use function like if(view == internal){player.invisible = on; cockpit_panel.visible = on;}
second thing... strange ship steering

Last edited by tompo; 05/09/07 14:30.

Never say never.
Re: question about ent_create [Re: tompo] #128881
05/09/07 14:28
05/09/07 14:28
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
should`nt sed say if theres an endless loop? but i`m a bit confused it says you have to have a wait before an ent create instruction so whats causeing the loop? is it the while part? but don`t i need that for the mouse.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: question about ent_create [Re: jigalypuff] #128882
05/09/07 14:33
05/09/07 14:33
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
An endless loop error occurs when a loop has looped more than max_loops in the same frame, but you have a wait, so it is only looping once every frame, and therefore you will not get the "possible endless loop" error.
But actually, it is endless: it runs as long as 1 == 1, and that (of course) is always true.

EDIT: This is how you should do it:
Code:
function update_mouse()
{
mouse_map = hempire_pcx;
mouse_mode = 1;

while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (1);
}
}

function main()
{
level_load("darkfrontiers.wmb");
wait (3);
update_mouse();
ent_create(galor_mdl,vector(0,0,0),c_ship);

}



Last edited by Claus_N; 05/09/07 14:36.
Re: question about ent_create [Re: Claus_N] #128883
05/09/07 14:36
05/09/07 14:36
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
loop is ok... he needs it to mouse move... it's normal loop while(1){...wait(1);} and after 3 cycles player is creating but only once. This part is ok.
You've wrote the same but in two different functions

Last edited by tompo; 05/09/07 14:38.

Never say never.
Re: question about ent_create [Re: tompo] #128884
05/09/07 14:38
05/09/07 14:38
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Quote:

loop is ok... he needs it to mouse move... it's normal loop while(1){...wait(1);} and after 3 cycles player is creating but only once. This part is ok.



Yes, the loop is necessary, but it should be in a separated function, as it is endless.

Re: question about ent_create [Re: Claus_N] #128885
05/09/07 14:39
05/09/07 14:39
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
cool got it working thanks guys.


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: question about ent_create [Re: Claus_N] #128886
05/09/07 14:41
05/09/07 14:41
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
but the problem is with camera, You can't see the player... but You didn't show us a camera script maybe player is there but you can't see him because camera is looking in wrong direction.
and you should first write ent_create then use the loop.

Last edited by tompo; 05/09/07 14:45.

Never say never.
Re: question about ent_create [Re: tompo] #128887
05/09/07 14:58
05/09/07 14:58
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@tompo: Nope. That is not the problem. Claus_N described exactly what the problem is.
Short example Code:

var a;

function some_func()
{
a = 5;
while(1) { wait(1); }
a = 2;
}


Now what will happen:
We have a var "a" and a function.
Now when the "engine" enters the function it sets a to the value "5".
After that it enters the while(1) loop and will stay inside of it forever.
Why? Because this is always true: 1 == 1
Thats why a will never become "2"

And that was exactly the same problem in jigalypuff's code.

Page 1 of 2 1 2

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