Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
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
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 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
how to acces a variable from a different script...and so #344049
10/13/10 10:55
10/13/10 10:55
Joined: Sep 2010
Posts: 82
P
peteredlin Offline OP
Junior Member
peteredlin  Offline OP
Junior Member
P

Joined: Sep 2010
Posts: 82
Hello now i need to know how to deal with variables, i knew but i forgot and cant find what i am looking for in the manuel.

I have a main script which loads a sub sript(include) which got a function which got a parameter which need to be loaded from within the main script when calling the function.

How can i do this?

Re: how to acces a variable from a different script...and so [Re: peteredlin] #344050
10/13/10 11:15
10/13/10 11:15
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hello,

I don't really understand the question, can you put some code? Because normally you can pass the parameter to the function when you call it. You can even create some global variable, set it from the main script and then use it in your function (but I think that's not really clean).

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
P
peteredlin Offline OP
Junior Member
peteredlin  Offline OP
Junior Member
P

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 Online
Senior Expert
Quad  Online
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 Online
Senior Expert
Quad  Online
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

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