Okay say char A walks up to switch and clicks it well switch changes id to look like its been fliped. now the gate should open.
I'm not sure how to make this happen i looked though all the js doc and i can not find any functions that will clal a nother item to move
triggering item effect
-
dragon slayer
- UOX3 Guru
- Posts: 776
- Joined: Thu Dec 21, 2006 7:37 am
- Has thanked: 4 times
- Been thanked: 26 times
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
One way of doing it would be to somehow save the serial of the item you want to be the "gate", as custom tags on the item you want to be the lever. Then, when the lever is used, you can fetch the JS object for the gate in the lever's script, based on those serials.
Here's some (untested) example JS Command for linking a lever and a gate, and then afterwards a sample-script to fetch the gate-object in the lever's onUseChecked() script, manipulate it's Z position, start timer on gate to reset it's position after 20 seconds, and another timer on the lever to switch gfx back to default:
OnUseChecked() sample:
Here's some (untested) example JS Command for linking a lever and a gate, and then afterwards a sample-script to fetch the gate-object in the lever's onUseChecked() script, manipulate it's Z position, start timer on gate to reset it's position after 20 seconds, and another timer on the lever to switch gfx back to default:
Code: Select all
function CommandRegistration()
{
RegisterCommand( "linkgate", 2, true ); //Lets GMs link a gate to a lever
}
function command_LINKGATE( pSock, execString )
{
pSock.CustomTarget( 1, "Select the lever you wish to link to a gate:" );
}
function onCallback1( pSock, myTarget )
{
var pUser = pSock.currentChar;
if( !pSock.GetWord( 1 ) && myTarget.isItem && pSock.clickX != 1)
{
pSock.tempObj = myTarget;
pSock.clickX = 1;
pSock.CustomTarget( 1, "Select the gate you wish to link the selected lever to:" );
}
else if( !pSock.GetWord( 1 ) && myTarget.isItem && pSock.clickX == 1)
{
var leverObj = pSock.tempObj;
var gateObj = myTarget;
leverObj.SetTag( "gateSer1", gateObj.GetSerial(1) );
leverObj.SetTag( "gateSer2", gateObj.GetSerial(2) );
leverObj.SetTag( "gateSer3", gateObj.GetSerial(3) );
leverObj.SetTag( "gateSer4", gateObj.GetSerial(4) );
pUser.SysMessage( "The selected lever has been linked to the selected gate." );
pSock.clickX = null;
}
else
pUser.SysMessage( "You need to target an item." );
}Code: Select all
function onUseChecked( pUser, iUsed )
{
//Fetch gateObj from custom tags saved on lever
var gateObj = CalcItemFromSer( iUsed.GetTag( "gateSer1"), iUsed.GetTag( "gateSer2"), iUsed.GetTag( "gateSer3"), iUsed.GetTag( "gateSer4"));
if( gateObj.morex != 0 )
{
if( iUsed.id == 0xXXXX )
{
//Move gate up 20 z, start timer to lower it back down
gateObj.z += 20;
gateObj.StartTimer( 20000, 2, true );
//Change lever gfx, and start short timer to change it back after a second or so:
iUsed.id = 0xYYYY;
iUsed.StartTimer( 1000, 1, true )
}
else
pUser.SysMessage( "You must wait a second before interacting with this lever again." );
}
else
pUser.SysMessage( "The gate is already open." );
return false;
}
function onTimer( myObj, timerID )
{
if( timerID == 1 )
{
//Change lever gfx back
if( myObj.id == 0xYYYY )
myObj.id = 0xXXXX;
}
else if( timerID == 2 )
{
myObj.z -= 20;
}
}-= Ho Eyo He Hum =-
-
dragon slayer
- UOX3 Guru
- Posts: 776
- Joined: Thu Dec 21, 2006 7:37 am
- Has thanked: 4 times
- Been thanked: 26 times