Author Sticky: Post Working Scripts Here
Adam_wasserman Posted: Sunday, 30 June 08:36AM
Rotation Script


Conversation:
=============

NWScript:
Root

01) +---[Owner]: It looks like this object can be rotated, do you want to try?

02)  . . . +---[Player]: Yes

03)  . . . | . . +---[Owner]: You try, but are not strong enough to get it to move. [End Dialogue]

04)  . . . | . . +---[Owner]: What degree would you like to rotate it to? 

05)  . . . | . . . . . +---[Player]: 45 degrees [End Dialogue]

06)  . . . | . . . . . +---[Player]: 90 degrees (South) [End Dialogue]

07)  . . . | . . . . . +---[Player]: 135 degrees [End Dialogue]

08)  . . . | . . . . . +---[Player]: 180 degrees (East) [End Dialogue]

09)  . . . | . . . . . +---[Player]: 225 degrees [End Dialogue]

10)  . . . | . . . . . +---[Player]: 270 degrees (North) [End Dialogue]

11)  . . . | . . . . . +---[Player]: 315 degrees [End Dialogue]

12)  . . . | . . . . . +---[Player]: 360 degrees (West) [End Dialogue]

13)  . . . +---[Player]: No [End Dialogue]



Now, in order to get this to function properly, you must attach some scripts to certain lines of dialogue.

On line 03, click the "Text appears when..." tab and add the following script:

NWScript:
int StartingConditional()

{

    int iResult;

    iResult = GetSkillRank( ABILITY_STRENGTH, GetPCSpeaker() ) > 14;

    return iResult;

}



This script makes a strength check and uses that to determine whether to give the next set of choices to the player. Players that are not strong enough do not get to rotate the object.

It is also necessary to add the rotation scripts to lines 05 - 12. They all have the same format, the only thing that needs to be changed is the variable fDegreeRotation :

NWScript:
void main() {

    float fDegreeRotation = 45.0;

    object oItem = GetItemActivated();

    float fItemFacing = GetFacingFromLocation( GetLocation(oItem) );

    fItemFacing += fDegreeRotation;

    SetFacing(fItemFacing);

}



The last step is to attach the following script to the onUsed event of the object you wish to rotate, where CONVERSATION_NAME is the name of the conversation file you just made:

NWScript:
void main(){

    ActionStartConversation( GetLastUsedBy(), "CONVERSATION_NAME", FALSE);

}



Please feel free to send questions to draelons@hotmail.com