Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,490 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How can you control an entity? #231308
10/13/08 17:21
10/13/08 17:21
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
I'm trying to create a simple top down shooter. Now I know that you can get an entity on screen creating an action and assigning an action to a model in the level editor.

This is fine but limited. I can't control a player once he dies and "respawn".

basically I want create an entity by creating a model through c_script. How can I do a entity.visible instruction, and actually allow the ship to be controlled?

If I do something Like this:

entity player_ship
{
type = "playership.mdl"
x = ;
y = ;
z = ;

on_Leftarrow = my.y = 20++ ;//move instruction

}

I guess what I'm getting at is can I call functions through an entity? or will this give me errors.

Sorry its a bit verbose but I'd appreciate any help you all can provide.

Re: How can you control an entity? [Re: Thehawk] #231316
10/13/08 18:07
10/13/08 18:07
Joined: Nov 2005
Posts: 66
Spokane, WA, USA
Vonman Offline
Junior Member
Vonman  Offline
Junior Member

Joined: Nov 2005
Posts: 66
Spokane, WA, USA
I've never tryed to move an entity outside a actual ACTION or FUNCTION but one thing I noticed is that you don't have a LOOP going..

The way your code looks to me now, assuming errorless, if you were to have the left arrow held down right before the entity was created AND held it til after it's creation, it would move 20 points down the y axis only ONE time because the code is not in a WHILE(1) loop.

If I was writing that exact code, it would probably be more like this:

(within your function)

//////////////
while(1) // WHILE 1 equalls true (it always does)

{


MY.Y -= key_force.x * 20;
wait(1); // put a wait(1) instruction so the loop won't crash.
}
/////////////////

I noticed you have the following code in there:

/////
x = ; // x equals 0
y = ; // y equals 0
z = ; // z equals 0
/////


If you have THAT within a while loop, then in every single frame, x,y, and z will all be set to zero.. If that happens, your object will become stationary, it will not move because every single frame your x,y,z coords are being set to zero.

But with the other code (theoreticaly) the left errow should cause MY.Y to move
20 quants down the Y axis EVERY single frame. If you are running at 200 frames per second, thats 4000 quants for every second you hold the right or left arrow keys (a bit FAST, you might want to try a much lower value).

To sum it up, simply put, you just need to code movement WITHIN a WHILE loop or it won't "REFRESH" every frame.

Re: How can you control an entity? [Re: Vonman] #231376
10/14/08 04:43
10/14/08 04:43
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
thanks vonman! I'm coming from blitz basic. in there I'd simply do a function player. They have an inbedded function called createentity().

This is simply set equal to your entity model.

Can I create a player in a function?

Re: How can you control an entity? [Re: Thehawk] #231390
10/14/08 07:54
10/14/08 07:54
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Originally Posted By: Thehawk

Can I create a player in a function?


look up ent_create in the manual. It will create your .mdl file and you can assign an action/function to it.

Re: How can you control an entity? [Re: DJBMASTER] #232493
10/21/08 23:48
10/21/08 23:48
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thanks DJ. I feel like such a newbie. I tried the ent_create function. But for some reason, this line:

player_ship = ent_create ("player_ship", temp, move_bullet1);

generates an error. I keep getting an error message that says the keyword is unknown. I checked the syntax.

its supposed to be

ent_create (string, vector, function or action);

what am I missing? I also have this at the end of my file. Should I put this command in a different spot?

Re: How can you control an entity? [Re: Thehawk] #232497
10/22/08 00:51
10/22/08 00:51
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Hi there,
Did you define an entity pointer?

ENTITY* player_ship;

Also try to change this in your code:

player_ship = ent_create("modelname.mdl", temp, move_bullet1);


cheers

Re: How can you control an entity? [Re: zwecklos] #232500
10/22/08 01:50
10/22/08 01:50
Joined: Sep 2002
Posts: 199
Chicago, Illinois
Thehawk Offline OP
Member
Thehawk  Offline OP
Member

Joined: Sep 2002
Posts: 199
Chicago, Illinois
Hello,

I just tried that. And its still doing the same thing. does the definition need to be right above the call to the entity?


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