player

Posted By: DAVIDMORETON

player - 04/03/16 11:46

Hi Folks,
I want my player to move with a platform (when he steps onto it and the platform is triggered).
I have tried 'PIBiped01' and 'player' in my script (c-script), but they do not work.
Is there another 'name ' to call the player please?

.....example
{
while(platform.x<300)
{
platform.x+=3*time-step;
player.x+=3*time_step; //'player' does not work!
wait(1);
....
David
Posted By: EpsiloN

Re: player - 04/03/16 15:37

I think all template scripts use the player pointer.

See if the mistake is somewhere else in your code...
Posted By: Reconnoiter

Re: player - 04/03/16 15:59

I never personally worked with c-script and the templates, but I heard the templates can be buggy. Also c-script is really old right? I would recommend switching to lite-c (check "How to convert C-Script code to lite-C" in the manual), it should not be to hard unless it is a really big project ofcourse. Also as soon it is lite-c, probably many more people will be able to help you (atleast I can than grin ).
Posted By: DAVIDMORETON

Re: player - 04/04/16 09:08

Thanks Epsilon and Reconnector for you answers - I have added the actual code to my query - does this help?
It is what to call the player that is the problem - any ideas please?
David
Posted By: Reconnoiter

Re: player - 04/04/16 11:14

First check if player isn't null. The following is for lite-c but might also work for c-script:

if (player == null) error("player pointer is null");


And also try;

if (!player) error("player pointer is not valid");


If no error message pops up, than you have some kind of weird memory error or such, or it is some bug (older version?).
If an error message does pop up, if it is for the if() than you haven't set the player pointer correctly or is set null somewhere in your code.
If an error message pops up and it is in the second if() than the pointer to the player is not valid anymore. Perhaps after loading a savegame??
Posted By: EpsiloN

Re: player - 04/04/16 11:42

Reconnoiter, from what I remember, I think you need braces in C-Script (one-liners didn't work), but I may be wrong...

DAVIDMORETON, I guess you assigned the action in WED, right?
Try doing it the dynamic way, in your main function:
Code:
player = ent_create("player.mdl",vector(0,0,32),template_function);


This is in case the templates don't assign the player pointer to the actual player... This way you assign it explicitly when you're creating the entity.

PS.: I hope you understand enough to substitute the values in my example, eg. the position from WED and the function/action from the template scripts.
Oh, and I think "error" isn't available in the old C-Script. Use beep();
Posted By: DAVIDMORETON

Re: player - 04/04/16 11:46

Thanks to all who helped.
I have now solved the problem - after much (hours) fiddling about and trying everything I could think of - the name to call the player such that it will move along with a platform is
piBiped01_entity....
Could not find this anywhere in the manual or templates!
This might be useful to others with the same problem
Once again, thanks for your help.

so the code is:-
......
{
while(platform.x<300)
{
platform.x+=3*time_step;
piBiped01_entity.x+=3*time_step;
wait(1);
.....
David
Posted By: Reconnoiter

Re: player - 04/04/16 13:10

Your welcome.

Originally Posted By: DAVIDMORETON
- the name to call the player such that it will move along with a platform is
piBiped01_entity.... Could not find this anywhere in the manual or templates!
This might be useful to others with the same problem
, I have a better idea, ditch those templates as soon as you can.

If you want some templates for Lite-c, I can write you some small ones and Realspawn also has quite a nice selection for beginners to Lite-c (http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=458483#Post458483).

cheers
Posted By: DAVIDMORETON

Re: player - 04/04/16 16:14

Many thanks for your kind offer Reconnoiter - I don't like to be a nuisance - but sometimes I get stuck when I can't find the necessary data in the manual.
I intend to covert my code to lite-c when I have completed this section of the game (it's quite a lot of code!)
Kind regards, David
© 2024 lite-C Forums