Character script name usage

Started by Kinoko, Mon 20/02/2006 10:57:50

Previous topic - Next topic

Kinoko

Sorry to start a whole topic about this, but... if I'm writing my own function, what do I write as a parameter if I want to be able to call a character's script name? Also, can I set a variable to a character's script name? If so, can I use that variable in place of the character's script name in front of a function?

kind of like;

if (blah blah) thisthing = cEgo;

function (int charid) {
  if (charid==cEgo) blah;
  charid.Walk(blah);

etc.


Gilbert

Due to the OO update of the engine and backward compatibility, you can do this in various favours now.
1. Use Character*:
function (Character* charpointer) {
Ã,  if (charpointer==cEgo) blah;
Ã,  charpointer.Walk(blah);Ã, 

2. Use the ID, or type int:
function (int charid) {
Ã,  if (charid==cEgo.ID) blah;
Ã,  character[charid].Walk(blah);


Kinoko

Thanks!! You just saved me many lines of code ^_^

(All due thanks to CJ for making the scripting awesome in the first place)

Ashen

Also, the script name can still be used as an int (not the script-o-name, so EGO not cEgo) equilvalent to Character.ID, as you're doing with Bernie's FollowCharacter module. So, a third way:

function (int charid) {
  if (charid==EGO) blah;
  character[charid].Walk(blah);
I know what you're thinking ... Don't think that.

Kinoko

So there's no way I can just assign a char o-name in a normal script, like:

girl = cBryn;

?

Gilbert

If girl is of type Character*, then Yes:

Character* girl;
girl = cBryn;

Kinoko

#6
Ah! Fantastic! :D Thanks.

EDIT: How do I define Character* girl;  ?

I get errors when I stick it in my global script with all the other defines. Plus, Character* doesn't turn blue like 'int' and 'string', so...

Pumaman

Yes, just putting

Character* girl;

in your script, wherever you would normally use

int blah;

or whatever is fine.
If you're having errors, could you post the error message and a snippet of the script you're using?

SMF spam blocked by CleanTalk