|
|
Re: how to acces a variable from a different script...and so
[Re: 3dgs_snake]
#344052
10/13/10 11:18
10/13/10 11:18
|
Joined: Sep 2010
Posts: 82
peteredlin
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2010
Posts: 82
|
mainscript /////////////////////////////////////////////////////////////// #include <acknex.h> #include <default.c> #include "level\\loadlevel.c" #include "truck\\truck.c" ///////////////////////////////////////////////////////////////
function main() { load_level(); truck(0,0,0); }
subscript /////////////////////////////////////////////////////////////// #include <chasis\\chasis.c> ///////////////////////////////////////////////////////////////
function truck(spawnp) { chasis(spawnp); }
subscript2 #include <suspencion\\suspencion.c> ///////////////////////////////////////////////////////////////
ENTITY* chasis;
function chasis(spawnp) { suspencion(); chasis = ent_create("truck\\chasis\\chasis.mdl",spawnp,NULL); ph_setgravity (vector(0, 0, -386)); // set the gravity phent_settype (chasis, PH_RIGID, PH_BOX); // set the physics entity type phent_setmass (chasis, 300, PH_BOX); // and its mass phent_setfriction (chasis, 80); // set the friction phent_setdamping (chasis, 40, 40); // set the damping phent_setelasticity (chasis, 100, 20); // set the elasticity }
thats the code, hope it helps
Last edited by peteredlin; 10/13/10 11:20.
|
|
|
Re: how to acces a variable from a different script...and so
[Re: peteredlin]
#344053
10/13/10 11:19
10/13/10 11:19
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
just directly call the function.
there is no such thing as sub-script all your code files together are your script. "#include"ing af file nearly same as writing everyting on that file instead of that #include.
you both have a fonction named chasis and an ENTITY* named chasis, you cannot do that.
also functions need to know it's parameter's type. and function does not directly RUN(apart from main), you have to call it somewhere.
also the convention is to include all your files at the begining of your script.
Last edited by Quadraxas; 10/13/10 11:22.
3333333333
|
|
|
Re: how to acces a variable from a different script...and so
[Re: Quad]
#344054
10/13/10 11:24
10/13/10 11:24
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
your script should probably be something like this:
mainscript /////////////////////////////////////////////////////////////// #include <acknex.h> #include <default.c> #include "level\\loadlevel.c" #include "truck\\truck.c" ///////////////////////////////////////////////////////////////
function main() { load_level(); VECTOR point; vec_set(point,vector(0,0,0)); truck(point); }
subscript /////////////////////////////////////////////////////////////// #include <chasis\\chasis.c> ///////////////////////////////////////////////////////////////
function truck(VECTOR* spawnp) { chasis_setup(spawnp);
}
subscript2 #include <suspencion\\suspencion.c> ///////////////////////////////////////////////////////////////
ENTITY* chasis;
function chasis_setup(VECTOR* spawnp) { suspencion();
chasis = ent_create("truck\\chasis\\chasis.mdl",spawnp,NULL); ph_setgravity (vector(0, 0, -386)); // set the gravity phent_settype (chasis, PH_RIGID, PH_BOX); // set the physics entity type phent_setmass (chasis, 300, PH_BOX); // and its mass phent_setfriction (chasis, 80); // set the friction phent_setdamping (chasis, 40, 40); // set the damping phent_setelasticity (chasis, 100, 20); // set the elasticity }
did not checked it all, but it should be something like this.
3333333333
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|