Unable to Run My Scripts


#21

I tried that last night, but it did not work either. I did run rs ga_party_limit(6) yesterday and that worked!


#22

What is the , ofc?


#23

huh… literally the only other thing I can think of is that the engine isn’t getting access to the scripts. (which on the face of it suggests that they aren’t in the right /Override directory, but am sure you’ve looked at that 15 times already.) Are you running the executable from a shortcut with a -home parameter (?) that points to a different player-folder (ie, a different Documents folder)

ofc = of course


#24

No. This is my shortcut for the game: “F:\NWN2 Complete\nwn2.exe”
This is my shortcut for the toolset: “F:\NWN2 Complete\NWN2ToolsetLauncher.exe”

Also, giveitem is working with the UTI files I put in the override folder.


#25

uh why copy them there? (scripts can be opened in the toolset and compiled directly from /Override) and why not their corresponding .nss files also?

/getting picky


#26

I guess I never fiqured out how to do that. Right now I have 73 ncs files in the override folder (a lot for not being able to run them!), so would I want the nss files there too?

I had a hard time getting the toolset to find my nss files. To create items, I had to make a mod to be able to access items. When I saved an item, I could point it to the override folder, but it defaulted to the module folder. So I always open my mod file first. After I open it, there is no longer a temp folder. When I save the mod file it saves my scripts and items.

I originally created erf files from the Aurora toolset and imported them. After I compiled them, it would create a temp folder and then I could retrieve them or add others to it. If you look at the photo above, it says the compiled script has been placed in a temp folder. So, if there is an easier way, I would love to learn it!

I see it now “Open Conversation/Script”. I don’t know how I missed it! I open that all the time and use Filter Text by adding aces_ to find my scripts. Wow!


#27

:popcorn:


#28

I just copied my ncs files from the My Documents override to the game folder override just to be sure. They still won’t run.


#29

It’s not code blocks and should I use them for code or not, the issue that what someone types is not what shows up on the page. If I type a quote mark, I should get a quote mark.


#30

try keeping the .nss/.ncs files together – it shouldn’t be necessary for non-gui scripts (but it strikes me as a good idea to keep them together anyway.)

resorting to the installation folder ought be unnecessary … scripts once compiled should run from the <documents>/Neverwinter Nights 2/Override folder (or any of its subfolders) in debugmode 1

 
as a workaround/test … in your work-module, place a lever that starts a custom dialog that tries to fire the custom scripts …

if that works, such a dialog could perhaps be started from a custom item’s OnActivated script (such an item granted w/ “giveitem” at the console)


#31

Here is why that has been included. So now you know who to blame.

TR


#32

(I reached the most replies a new user can add - so I had to wait 5 hours to send this - too bad it doesn’t tell the person you are replying to as well)

I can see that the only way to compile the scripts, other than from the temp folder, is from the game folder override or sub-folder. I tried that and it worked nicely.

I am not sure what exactly you are talking about, but it gave me an idea. I thought I had a way to do it just by creating an item to get using giveitem, activate it on myself and let it run my script.

In this case I create a script to add and equip my armor:

/******************************

Created by dwharper34 aka AcesHigh

       November 14, 2018

Equip Ace's Dragon Plate Armor & Jewelry onto Player

aces_armor_007     Ace's Red Dragon Armor
aces_helm_007      Ace's Red Dragon Plate Helmet
aces_boots_002     Ace's Red Dragon Plate Boots
aces_cloak_002     Ace's Cloak of Protection
aces_belt_001      Ace's Greater Belt
aces_gloves_005    Ace's Red Dragon Scale Gloves
aces_neck_001      Ace's Amulet of Health
aces_ring_001      Ace's Regeneration Ring
aces_ring_002      Ace's Ring of Immunity

    aces_dragonplate

******************************/

int CreateNewItems(string sItemID, object oUser, int nQty, int nStackSz)
{
 if(nQty==0)
 {
  nQty=1;
 }
 int nNumMade=0;
 int nIndex;

 for (nIndex=1; nIndex <= nQty; nIndex++)
 {
  object oNewItem=CreateItemOnObject(sItemID, oUser, nStackSz);
  {
   if(oNewItem==OBJECT_INVALID)
   {
    return FALSE;
   }
   else
   {
    nNumMade++;
   }
  }
 }
 return nNumMade;
}

void AddItems(string sItemTag, string sItemType, int nItemCnt, int nStackSz)
{
 object oPC=OBJECT_SELF;
 object oNewItem=GetObjectByTag(sItemTag,0);
 string sMsg;

 int nCreated=CreateNewItems(sItemTag, oPC, nItemCnt, nStackSz);
 {
  if(nCreated)
  {
   sMsg=IntToString(nCreated) + sItemType + "Items Added!";
   FloatingTextStringOnCreature(sMsg, oPC);
  }
  else
  {
   FloatingTextStringOnCreature(sItemTag, oPC);
   sMsg="Error . . . No" + sItemType + "Items Added!";
   FloatingTextStringOnCreature(sMsg, oPC);
  }
 }
}

void EquipItems()
{
 string sAARM="aces_armor_007";
 string sAHLM="aces_helm_007";
 string sABTS="aces_boots_002";
 string sACLK="aces_cloak_002";
 string sABLT="aces_belt_001";
 string sAGLV="aces_gloves_005";
 string sANCK="aces_neck_001";
 string sARNG1="aces_ring_001";
 string sARNG2="aces_ring_002";
 object oPC=OBJECT_SELF;
 object oItemHelm=GetObjectByTag(sAHLM,0);
 AssignCommand(oPC, ActionEquipItem(oItemHelm, INVENTORY_SLOT_HEAD));
 object oItemArmor=GetObjectByTag(sAARM,0);
 AssignCommand(oPC, ActionEquipItem(oItemArmor, INVENTORY_SLOT_CHEST));
 object oItemBoots=GetObjectByTag(sABTS,0);
 AssignCommand(oPC, ActionEquipItem(oItemBoots, INVENTORY_SLOT_BOOTS));
 object oItemGloves=GetObjectByTag(sAGLV,0);
 AssignCommand(oPC, ActionEquipItem(oItemGloves, INVENTORY_SLOT_ARMS));
 object oItemCloak=GetObjectByTag(sACLK,0);
 AssignCommand(oPC, ActionEquipItem(oItemCloak, INVENTORY_SLOT_CLOAK));
 object oItemRing1=GetObjectByTag(sARNG1,0);
 AssignCommand(oPC, ActionEquipItem(oItemRing1, INVENTORY_SLOT_LEFTRING));
 object oItemRing2=GetObjectByTag(sARNG2,0);
 AssignCommand(oPC, ActionEquipItem(oItemRing2, INVENTORY_SLOT_RIGHTRING));
 object oItemNeck=GetObjectByTag(sANCK,0);
 AssignCommand(oPC, ActionEquipItem(oItemNeck, INVENTORY_SLOT_NECK));
 object oItemBelt=GetObjectByTag(sABLT,0);
 AssignCommand(oPC, ActionEquipItem(oItemBelt, INVENTORY_SLOT_BELT));
}

void main()
{
 object oPC=GetPCSpeaker();
 string sType;
 int nStackSz;
 string sAARM="aces_armor_007";
 string sAHLM="aces_helm_007";
 string sABTS="aces_boots_002";
 string sACLK="aces_cloak_002";
 string sABLT="aces_belt_001";
 string sAGLV="aces_gloves_005";
 string sANCK="aces_neck_001";
 string sARNG1="aces_ring_001";
 string sARNG2="aces_ring_002";

 sType=" Armor ";
 nStackSz=1;
 AddItems(sAARM,sType,1,nStackSz);
 AddItems(sAHLM,sType,1,nStackSz);
 AddItems(sABTS,sType,1,nStackSz);
 AddItems(sACLK,sType,1,nStackSz);
 AddItems(sABLT,sType,1,nStackSz);
 AddItems(sAGLV,sType,1,nStackSz);

 sType=" Jewelry ";
 nStackSz=1;
 AddItems(sANCK,sType,1,nStackSz);
 AddItems(sARNG1,sType,1,nStackSz);
 AddItems(sARNG2,sType,1,nStackSz);

 EquipItems();

 OpenInventory(oPC, oPC);
}

Then I create an item to install it with. In this case I used the Orb of Summoning with a few changes.

Then I create a ScriptSet called Aces_DragonPlate.xml to run the script aces_dragonplate.ncs.

Aces_DragonPlate%20ScriptSet

And use import properties to import it into my orb, Equip Ace’s Red Dragon Armor.

Import%20Aces_DragonPlate%20ScriptSet

Anyway, that was the idea, but it doesn’t look like the properties get updated when I import them. Any ideas?

If there is another way I can run my scripts, I would appreciate knowing it.


#33

I got this to work after I found the “Item Activate.nss” template. My orbs item ID was aces_orb_001, so I had to create a new script named i_aces_orb_001_ac and it is below:

// i_aces_orb_001_ac
/*
   Template for an Activate item script.
   This script will run each time an item's "custom activation" is used.
   
   How to use this script:
   Item needs an item property that will cause a custom activation such as Cast Spell:Unique Power
   
   This script will be called automatically (by defualt) whether it exists or not.  If if does not exist, nothing happens.
   
   Note: this script runs on the module object, an important consideration for assigning actions.
      -ChazM
*/
// AcesHigh		November 14, 2018

int CreateNewItems(string sItemID, object oTarget, int nQty, int nStackSz)
{
 if(nQty==0)
 {
  nQty=1;
 }
 int nNumMade=0;
 int nIndex;

 for (nIndex=1; nIndex <= nQty; nIndex++)
 {
  object oNewItem=CreateItemOnObject(sItemID, oTarget, nStackSz);
  {
   if(oNewItem==OBJECT_INVALID)
   {
    return FALSE;
   }
   else
   {
    nNumMade++;
   }
  }
 }
 return nNumMade;
}

void AddItems(string sItemTag, string sItemType, int nItemCnt, int nStackSz, object oTarget)
{
 object oNewItem=GetObjectByTag(sItemTag,0);
 string sMsg;

 int nCreated=CreateNewItems(sItemTag, oTarget, nItemCnt, nStackSz);
 {
  if(nCreated)
  {
   sMsg=IntToString(nCreated) + sItemType + "Items Added!";
   FloatingTextStringOnCreature(sMsg, oTarget);
  }
  else
  {
   FloatingTextStringOnCreature(sItemTag, oTarget);
   sMsg="Error . . . No" + sItemType + "Items Added!";
   FloatingTextStringOnCreature(sMsg, oTarget);
  }
 }
}

void EquipItems(object oTarget)
{
 string sAARM="aces_armor_007";
 string sAHLM="aces_helm_007";
 string sABTS="aces_boots_002";
 string sACLK="aces_cloak_002";
 string sABLT="aces_belt_001";
 string sAGLV="aces_gloves_005";
 string sANCK="aces_neck_001";
 string sARNG1="aces_ring_001";
 string sARNG2="aces_ring_002";
 object oItemHelm=GetObjectByTag(sAHLM,0);
 AssignCommand(oTarget, ActionEquipItem(oItemHelm, INVENTORY_SLOT_HEAD));
 object oItemArmor=GetObjectByTag(sAARM,0);
 AssignCommand(oTarget, ActionEquipItem(oItemArmor, INVENTORY_SLOT_CHEST));
 object oItemBoots=GetObjectByTag(sABTS,0);
 AssignCommand(oTarget, ActionEquipItem(oItemBoots, INVENTORY_SLOT_BOOTS));
 object oItemGloves=GetObjectByTag(sAGLV,0);
 AssignCommand(oTarget, ActionEquipItem(oItemGloves, INVENTORY_SLOT_ARMS));
 object oItemCloak=GetObjectByTag(sACLK,0);
 AssignCommand(oTarget, ActionEquipItem(oItemCloak, INVENTORY_SLOT_CLOAK));
 object oItemRing1=GetObjectByTag(sARNG1,0);
 AssignCommand(oTarget, ActionEquipItem(oItemRing1, INVENTORY_SLOT_LEFTRING));
 object oItemRing2=GetObjectByTag(sARNG2,0);
 AssignCommand(oTarget, ActionEquipItem(oItemRing2, INVENTORY_SLOT_RIGHTRING));
 object oItemNeck=GetObjectByTag(sANCK,0);
 AssignCommand(oTarget, ActionEquipItem(oItemNeck, INVENTORY_SLOT_NECK));
 object oItemBelt=GetObjectByTag(sABLT,0);
 AssignCommand(oTarget, ActionEquipItem(oItemBelt, INVENTORY_SLOT_BELT));
}

void main()
{
 object oPC = GetItemActivator();
 object oItem = GetItemActivated();
 object oTarget = GetItemActivatedTarget();
 location lTarget = GetItemActivatedTargetLocation();

 string sType;
 int nStackSz;
 string sAARM="aces_armor_007";
 string sAHLM="aces_helm_007";
 string sABTS="aces_boots_002";
 string sACLK="aces_cloak_002";
 string sABLT="aces_belt_001";
 string sAGLV="aces_gloves_005";
 string sANCK="aces_neck_001";
 string sARNG1="aces_ring_001";
 string sARNG2="aces_ring_002";

 sType=" Armor ";
 nStackSz=1;
 AddItems(sAARM,sType,1,nStackSz,oTarget);
 AddItems(sAHLM,sType,1,nStackSz,oTarget);
 AddItems(sABTS,sType,1,nStackSz,oTarget);
 AddItems(sACLK,sType,1,nStackSz,oTarget);
 AddItems(sABLT,sType,1,nStackSz,oTarget);
 AddItems(sAGLV,sType,1,nStackSz,oTarget);

 sType=" Jewelry ";
 nStackSz=1;
 AddItems(sANCK,sType,1,nStackSz,oTarget);
 AddItems(sARNG1,sType,1,nStackSz,oTarget);
 AddItems(sARNG2,sType,1,nStackSz,oTarget);

 EquipItems(oTarget);

 OpenInventory(oTarget, oPC);
}

I used DebugMode 1, then giveitem aces_orb_001and then DebugMode 0. I just used the Orb on myself, then passed it around to the companions I wanted to have the armor. I actually didn’t need to pass it around, I could have just activated the Orb and selected them as targets. At least that is how I wrote it. I will have to test it. Now this will save me a lot of time and maybe some of you can adapt it to use it too!

I still can’t run scripts from the console, but thanks to kevL_s, I came up with this idea! Thanks again!

Now at least I can make scripts to equip armor, weapons and other miscellaneous items. If anyone has any ideas how I can get my scripts to run on the console, I would love to here it!


#34

glad the workaround works,

another idea as to why a script fails at the console: if main() takes input parameters but they aren’t supplied or aren’t type-correct …

 
The Orb is what i was getting at, but instead of running a script itself, it starts a dialog instead. Each node in a dialog can then run - one or more of - your scripts.


#35

That’s a thought. I would need to talk to someone though right?


#36

nope. a PC can start a dialog with itself, sorta like

AssignCommand(oPC, ActionStartConversation(oPC, “dialog_file”);

(roughly)


#37

I’ll have to check it out. That would require a lot less orbs I think.


#38

It works fine. I have often used it.


#39

Overall the Orbs seem to work, except when a companion is using it. As long as I am using the Orb, it works as planned. When I give the Orb to a companion, the armor they choose doesn’t get equipped on them, it gets equipped on me and we switch locations!

The problem is the Orb uses: object oPC = GetItemActivator();. All the scripts getting called use object oPC=GetPCSpeaker();. I thought that since possibly a NPC might have control of the sphere that that would be appropriate, but I guess not. Since the script being called does not activate anything, the GetItemActivator() would not work there. It doesn’t appear that you can pass variables to the script being called. Maybe there’s a way though.

Do you have any ideas what would work? If anybody has any thoughts on this, I would appreciate it!

Note: After using the Orbs I have been able to run scripts again. They don’t always work like they should, but when using the Orbs they do. I am still trying to find out what is happening.


#40

in the Actionscripts, i’d likely use

object oTarget = GetPlayerCurrentTarget(GetPCSpeaker());

and my PC would use the Orb/dialog while having a Companion targeted. (uhh, i think player can keep a target when invoking a dialog …)

And perhaps assign a subfunction that runs, with the Companion as owner, to do the creating/equipping … very roughly:

// aces_wizard
void main()
{
    object oTarget = GetPlayerCurrentTarget(GetPCSpeaker());
    AssignCommand(oTarget, doWizardstuff());
}

void doWizardstuff()
{
   // OBJECT_SELF is the wizard companion here
}

So only the PC ever uses the Orb.


to be honest I’d combine all those action-scripts into one script and use a switch/case block to handle everything

// aces_equip
void main(int iCase)
{
    object oTarget = GetPlayerCurrentTarget(GetPCSpeaker());
    switch (iCase)
    {
        case 0:
            AssignCommand(oTarget, doWizard());
            break;
        case 1:
            AssignCommand(oTarget, doBard());
            break;
        case 2:
            AssignCommand(oTarget, doCityWatch());
            break;

        // etc...
    }
}

iCase can be passed to the script from the dialog node(s) [click “Refresh” in the dialog editor]

Note that there are various things that are at play. i won’t go into them but there are campaign settings, module settings, dialog settings, etc etc that affect the behavior you’re getting (and not getting). If you really had to, a variable can be passed to a script from another script by storing the variable on the module-object, the area-object, the PC-object … or any handy object …

/anyway, just some ideas to think about or so – tl;dr check out GetPlayerCurrentTarget()