Aller au contenu

Photo

TakeGold and TakeGoldFromCreature


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

#1
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
Just thought I'd share something I wandered across - and I'm sure others have too...

Contrary to what the Lexicon states, TakeGold and TakeGoldFromCreature can be made to fire from the Module's OnModuleLoad or an Area's OnEnter event by using this block of code:

ExecuteScript("script_name", GetEnteringObject());

Calling TakeGold or TakeGoldFromCreature from within the executed script bypasses the restriction upon the functions. Thus script_name.nss would look something like this:

void main()
{
     int nAmount = 100;
     TakeGoldFromCreature(nAmount, OBJECT_SELF, TRUE);
}

This would take 100 gold from the caller (the entering creature) and destroy it.

Can't help but woinder what other limitations can be bypassed by using the ExecuteScript function...

Modifié par Pstemarie, 26 janvier 2013 - 04:16 .


#2
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
I'd been using it from the start areas OnEnter in my mod, didn't even realize you weren't supposed to be able to.
I'd been using it assigned to the PC though, which is likely why it worked, and must be handled similarly by the engine for handling it through ExecuteScript.

#3
meaglyn

meaglyn
  • Members
  • 816 messages
I think the warning in the Lexicon is about having the area or module do the taking. Assigning it to someone else works and is what both ExecuteScript("foo", GetEnteringObject()) and
AssignCommand(GetEnteringObject(), Take...) do. I.e. they're essentially doing the same thing.

#4
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
Maybe we can get these updated in the Lexicon with the notation that ExecuteScript and AssignCommand will bypass the hard-coded limitation...

#5
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
This line was in there, already:

NWN Lexicon wrote...

The taker needs to be a non-area and non-module object for it to work correctly. It can be the creature passed into oCreatureToTakeFrom, of course.

I added the following to clarify:

NWN Lexicon wrote...

If the function caller (OBJECT_SELF) is the module or an area, this function will fail. If you want to use this function in an area or module event (like an area's OnEnter), you can use AssignCommand() or ExecuteScript() to assign the function to another object.