HorseCreateHorse

Why won’t this compile? It’s the lexicon example, but it gives duplicate function implementation error. It’s the same one used in Urk’s stable prefab except his uses tokens. Copying his gives same error when saving, but since his were compiled at some time, they work in his prefab.

 // An existing horse with a tag of "HorseTemplate" is used to create a new horse 
 // with a tag of "NewHorse" near the PC, who becomes the owner of the new horse.
 #include "x3_inc_horse"
  
  
 void main()
 {
    object oPC    = GetPCSpeaker();
    object oHorse = HorseCreateHorse(GetResRef(GetObjectByTag("HorseTemplate")), GetLocation(oPC), oPC, "NewHorse");
 }

end the statement with a semicolon instead of a comma, and add a closing parenthesis

object oHorse = HorseCreateHorse(GetResRef(GetObjectByTag(“HorseTemplate”)));
1 Like

This is all one line though. I’ll give it a whirl.

object oHorse = HorseCreateHorse(GetResRef(GetObjectByTag(“HorseTemplate”)), GetLocation(oPC), oPC, “NewHorse”);

EDIT: Nope, didn’t work. There’s something else wrong.

oh … the duplicate function needs to be tracked down … in ‘x3_inc_horse’ or its #includes

( i don’t have that #include myself thogh )

The function in the include is

object HorseCreateHorse(string sResRef,location lLoc,object oOwner=OBJECT_INVALID,string sTag="",int nAppearance=-1,int nTail=-1,int nFootstep=-1,string sScript="")

there might not be any problem with HorseCreateHorse()

A duplicate function error is more general. There can be only 1 declaration/implementation of any function ( eg. HorseCreateHorse() ) in a script, including its #includes

the function might not even be called in your script, but the compiler seems to be seeing two+ implementations of a function with the same name somewhere in the dependencies

Yeah, that’s weird because it would compile at one time or Urks scripts wouldn’t work. Trying to copy/paste them in new scripts wouldn’t compile and thus won’t work in my mod.

copy/pasting code generally throws its warranty out the window  ;)

all i can really say is that i think something got duplicated (or re-included) that shouldn’t …

The script in the OP compiles in both 1.69 and EE 1.80 (using the official compiler that ships with the toolset).

Perhaps you’re using a different compiler, or have edited x3_inc_horse?

It really helps to track down the issue if you link to the system(s) you use. There are several Urk’s horse contributions in the vault.

But which function? The compiler should say it in the error line.

The only function you have defined here is main(). So perhaps you (or someone) has uncommented main() in x3_inc_horse (or somewhere up the include chain from x3_inc_horse)?

The end of vanilla x3_inc_horse should look like this (note the //):

//void main(){}

I see the same question on the Beamdog forum has a different script with two main functions, so maybe that’s the problem?

The script wasn’t the problem. An old X0_INC_HENAI that I somehow acquired was the problem.

The problem is fixed. BTW though, that script was copied directly from the Lexicon. It’s not something I just pulled out of my butt.

Thanks for the help all of you.