Aller au contenu

Photo

quest script did not compile?


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Who said that I

Who said that I
  • Members
  • 492 messages
#include "nw_i0_plotwizard"
#include "NW_I0_GENERIC"
#include "pqj_inc"
void main()
{
    // Set the variables
    SetLocalInt(GetPCSpeaker(), "p021state", 300);
// Get the PC who is in this conversation.
    object oPC = GetPCSpeaker();
 
    // Update the player's journal.
    AddPersistentJournalQuestEntry("p021", 3, oPC, FALSE);
 
    // Spawn "creature007".
    oTarget = GetWaypointByTag("WP_SUBSTITTUTE_001");
    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature007", GetLocation(oTarget));
    AssignCommand(oSpawn, ActionStartConversation(oPC));
}

 

13-1-2016 8:33:10: Error. 'p021q003_action' did not compile.
p021q003_action.nss(17): ERROR: VARIABLE DEFINED WITHOUT TYPE
 
So the script is not compiling....how can I fix this? thanks! :D


#2
Failed.Bard

Failed.Bard
  • Members
  • 774 messages

oTarget = GetWaypointByTag("WP_SUBSTITTUTE_001");

 

needs to be:

 

object oTarget = GetWaypointByTag("WP_SUBSTITTUTE_001");

 

Undefined variables will throw that error.



#3
Baaleos

Baaleos
  • Members
  • 1 330 messages

Hi Who said that I

Some common terms to remember in programming is declaration and definition.

 

Declaring is when a variable is 'declared' as a type

Defining is when that variable is given a definition: Eg, this variable is specifically this monster

 

In programming, the declaration and definition can be separate lines, or as Failed.Bard pointed out, you can have them on the same line at the same time.

But you must always declare a type associated with the variable, otherwise when you try to use oTarget, the compiler does not know what type of object it is.

 

In most modern programming languages, they may be able to infer the type, from the method you are calling.

But NWScript is just a scripting language, and it is very old.

 

So you could have got your script working by doing one of the following:

#include "nw_i0_plotwizard"
#include "NW_I0_GENERIC"
#include "pqj_inc"
void main()
{
    // Set the variables
    SetLocalInt(GetPCSpeaker(), "p021state", 300);
// Get the PC who is in this conversation.
    object oPC = GetPCSpeaker();
 
    // Update the player's journal.
    AddPersistentJournalQuestEntry("p021", 3, oPC, FALSE);
 
    // Spawn "creature007".
    object oTarget;
    oTarget = GetWaypointByTag("WP_SUBSTITTUTE_001");
 
    or 
 
    object oTarget = GetWaypointByTag("WP_SUBSTITUTE_001");
    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature007", GetLocation(oTarget));
    AssignCommand(oSpawn, ActionStartConversation(oPC));
}