Solved Is it possible, or how can I use a @cmd within a @script?

Question that is answered or resolved.

PS_VITA

Active member
Hey guys,

for example I have a script...

@script
void vSelf = getlocalvar ("self");

if (frame==1)
{
// do something
}
@end_script

and I also have...

@cmd dasher 0 0 0

are there ways to combine these two without getting errors?

such as this...


@script
void vSelf = getlocalvar ("self");

if (frame==1)
{
@cmd dasher 0 0 0
}
@end_script

I've been curious about how this is done for a while or something similar to the example above.

Thanks
 
Solution
@PS_VITA

This question really has two parts.

The first is if you can call @cmd dasher inside @script tags. Yes and no. You can't combine @cmd with @script tags like that, but you don't need to and really wouldn't want to. The way to call dasher or any other function inside other code that is to use correct C syntax:

C:
@script
void vSelf = getlocalvar ("self");

if (frame==1)
{
     dasher(0, 0, 0);
}
@end_script

Now the second part... should you? Normally the answer is no. In your example case, absolutlety not. You are populating a self variable for no reason at all, then using logic to check if you're on frame 1 (which won't work anyway because you never populated the frame variable), and if so trying to run the dasher...
@PS_VITA

This question really has two parts.

The first is if you can call @cmd dasher inside @script tags. Yes and no. You can't combine @cmd with @script tags like that, but you don't need to and really wouldn't want to. The way to call dasher or any other function inside other code that is to use correct C syntax:

C:
@script
void vSelf = getlocalvar ("self");

if (frame==1)
{
     dasher(0, 0, 0);
}
@end_script

Now the second part... should you? Normally the answer is no. In your example case, absolutlety not. You are populating a self variable for no reason at all, then using logic to check if you're on frame 1 (which won't work anyway because you never populated the frame variable), and if so trying to run the dasher function. This makes no sense, because all you have to do is put @cmd on a frame, and that's the frame it runs on.

Code:
@cmd dasher 0 0 0
frame data/chars/dude/dude_sprite_0.png

HTH,
DC
 
Solution
@PS_VITA

This question really has two parts.

The first is if you can call @cmd dasher inside @script tags. Yes and no. You can't combine @cmd with @script tags like that, but you don't need to and really wouldn't want to. The way to call dasher or any other function inside other code that is to use correct C syntax:

C:
@script
void vSelf = getlocalvar ("self");

if (frame==1)
{
     dasher(0, 0, 0);
}
@end_script

Now the second part... should you? Normally the answer is no. In your example case, absolutlety not. You are populating a self variable for no reason at all, then using logic to check if you're on frame 1 (which won't work anyway because you never populated the frame variable), and if so trying to run the dasher function. This makes no sense, because all you have to do is put @cmd on a frame, and that's the frame it runs on.

Code:
@cmd dasher 0 0 0
frame data/chars/dude/dude_sprite_0.png

HTH,
DC



Thank you for the explanation,
I'm glad it can be done.
And yes, the script I showed above was just a random example and you are correct that it would make no sense to use it that way.
 
Back
Top Bottom