tChar, mChar, myChar, pCharacter

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
mikel123
UOX3 Neophyte
Posts: 27
Joined: Thu Aug 18, 2011 4:28 pm
Has thanked: 0
Been thanked: 0

tChar, mChar, myChar, pCharacter

Post by mikel123 »

tChar, mChar, myChar, pCharacter

What is the difference between these?

Bonus question: I have the following script for some jewelry of Agility:

Code: Select all

function onEquip(mChar, ourObj) 
{ 
 if (mChar.online == true) 
 { 
 if (ourObj.id == 0x1085 || ourObj.id == 0x1086 || ourObj.id == 0x1087 || ourObj.id == 0x1088 || 
ourObj.id == 0x1089 || ourObj.id == 0x108a || ourObj.id == 0x1f06 || ourObj.id == 0x1f07 || 
ourObj.id == 0x0f4b || ourObj.id == 0x0f4d || ourObj.id == 0x0f51 || 
ourObj.id == 0x1f08 || ourObj.id == 0x1f09 || ourObj.id == 0x1f0a) 
 {  
  mChar.tempdex=(mChar.tempdex +10);
  mChar.MagicEffect( 9 );
  mChar.SoundEffect( 0x1ee, true );
  mChar.StartTimer( 3000 , 9 );

} 
}
}

function onTimer( mChar , timerID )
{
 if ( timerID == 9 )
  {mChar.tempdex=(mChar.tempdex -10);
}
}
The first portion works well - when I equip the jewelry, I gain 10 dex, I see sparkles, and I hear the sound effect. The second portion (onTimer) does not work, and I can't figure out why.

As you might have guessed, I'm scouting some prior onTimer posts here, and it seems like all of them reference pCharacter, rather than mChar, so I feel like that might have something to do with it. But, replacing mChar with pCharacter in the onTimer portion of the script does not make it work either...
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

There is no difference between tChar, mChar, myChar, pCharacter. Which you use just depend on what you named the character object in your function header.

Example:
function onEquip(carrot, potatoe)
...works just as well as...
function onEquip(mChar, ourObj)
...you'd just have to replace all references inside your function to mChar with "carrot", and all references to ourObj with "potatoe".

For your timer-problem, try replacing...
mChar.StartTimer( 3000 , 9 );
with...
mChar.StartTimer( 3000 , 9, true );

Someone (*coughmecough*) should probably update the documentation for StartTimer so it actually reflects how the thing works. I'll quote the changelog for how it actually works:
StartTimer now looks like
BaseObject.StartTime( numMillis, TimerID[, optVal] );

optVal can either be a boolean (call back into this script, so we don't have to know it's number... this solves non-item/npc scripts so magic can work right) or an integer (the script number to call back into)
-= Ho Eyo He Hum =-
mikel123
UOX3 Neophyte
Posts: 27
Joined: Thu Aug 18, 2011 4:28 pm
Has thanked: 0
Been thanked: 0

Post by mikel123 »

Ahhhhh, I see. I was starting to get that impression as I was getting a little more daring (read: making stuff up) in my Healing.js file, and things seemed to continue to work.

Alright I'll give that a shot.

Also, speaking of which, if you find yourself with an abundance of time on your hands, one other thing that could use updating is this page:

https://www.uox3.org/documentation.shtml

Specifically the documentation links around AI type, item types, etc., are all broken.
mikel123
UOX3 Neophyte
Posts: 27
Joined: Thu Aug 18, 2011 4:28 pm
Has thanked: 0
Been thanked: 0

Post by mikel123 »

Works perfectly, thanks Xuri!
Post Reply