Server Totals
Le'Or - (1)
Wilderness - (1)
Ferrell - (0)
Elysia - (0)
M'Chek - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Mikona - (0)
Total players: 2
Gallery
  • Ebony Order
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Wed Aug 20, 2014 12:04 am

Links Menu

Script: Sit in Chair on Use

Moderators: Nighthawk4, Dungeon Masters

Script: Sit in Chair on Use

PostAuthor: Silk » Mon Jun 24, 2002 4:49 pm

This script will make PCs sit in a seat when used.

Make the chair useable and put this script in the OnUse event

Code: Select all
void main()
{
    object oPlayer = GetLastUsedBy();
    if (GetIsPC (oPlayer))
    {
        if (GetIsObjectValid( OBJECT_SELF) && !GetIsObjectValid( GetSittingCreature(OBJECT_SELF)))
        {
            AssignCommand(oPlayer, ActionSit(OBJECT_SELF));
        }
    }
}
Silk

Member of the MadK@t lover's group.
User avatar
Silk
Co-Founder
 
Posts: 6665
Joined: Fri Sep 14, 2001 6:47 pm

PostAuthor: Orleron » Mon Jun 24, 2002 5:18 pm

Cool, hey, question, what does it mean when there's an exclamation point in front of the function like in:

!GetIsObjectValid(GetSittingCreature(OBJECT_SELF))

??
"Truth has no form."
--Idries Shah

World of Avlis Page

Avlis Project FAQ
User avatar
Orleron
World Advisor, Co-founder
World Advisor, Co-founder
 
Posts: 14905
Joined: Fri Sep 14, 2001 9:48 pm
Timezone: GMT-5

PostAuthor: Prophet » Mon Jun 24, 2002 7:33 pm

! usually means NOT, but don't hold me to that. Looks like it might be right though.

Prophet
Apprentice Scholar
 
Posts: 579
Joined: Sat Oct 13, 2001 3:11 pm

PostAuthor: Silk » Mon Jun 24, 2002 7:56 pm

yes, logical NOT

This is what the script means (I speak logic):

> object oPlayer = GetLastUsedBy();

Return the Player that used the chair.

> if (GetIsPC (oPlayer))

If the player is a PC then do the following

> if (GetIsObjectValid( OBJECT_SELF) && !GetIsObjectValid(GetSittingCreature(OBJECT_SELF)))

If the chair exists and there is nothing sitting in it, then do the following (nested if here)

> AssignCommand(oPlayer, ActionSit(OBJECT_SELF));

Make the player sit in the chair.
Silk

Member of the MadK@t lover's group.
User avatar
Silk
Co-Founder
 
Posts: 6665
Joined: Fri Sep 14, 2001 6:47 pm

PostAuthor: Orleron » Mon Jun 24, 2002 8:36 pm

Why does your GetSittingCreature function call OBJECT_SELF. Aren't you supposed to be checking is other objects are sitting in it?
"Truth has no form."
--Idries Shah

World of Avlis Page

Avlis Project FAQ
User avatar
Orleron
World Advisor, Co-founder
World Advisor, Co-founder
 
Posts: 14905
Joined: Fri Sep 14, 2001 9:48 pm
Timezone: GMT-5

PostAuthor: Silk » Mon Jun 24, 2002 8:41 pm

Originally posted by Orleron
Why does your GetSittingCreature function call OBJECT_SELF. Aren't you supposed to be checking is other objects are sitting in it?


OBJECT_SELF is the used item (in this case the chair), GetSittingCreatures returns any creature that is sitting in the used item (the chair).
Silk

Member of the MadK@t lover's group.
User avatar
Silk
Co-Founder
 
Posts: 6665
Joined: Fri Sep 14, 2001 6:47 pm

PostAuthor: MacLeod » Tue Jun 25, 2002 4:15 am

Orleron, and other newbie scripters/programmers:

To reiterate what Silk just said in non-code terms, the ! logical not operator simply reverses the result of the values it's attached to, so:

Not false is equal to true
!false == true //statement is true
Not true is equal to false
!true == false

also:
true is not equal to false
true != false // statement is true

false is not equal to true
false != true // statement is true



The logical operators are something extremely important to understand, as you're going to have a <I>lot</i> of decision making code.

Unless somehow writing optimized code becomes a high priority (which I doubt for this), write everything to be highly readable, you're probably going to be changing things a lot. For the same reason, use assloads of comments, describing what you're doing at every important decision.
Duncan MacLeod,
Chessie Mage

"Alright now you sunsofbitches, you know how I feel"
~Jackyl, Open Invitation

MacLeod
Apprentice Scholar
 
Posts: 586
Joined: Fri Jan 11, 2002 11:29 pm

PostAuthor: myzmar » Thu Sep 16, 2004 6:29 am

Ok, total n00b as regards scripting here. Should I use this script when I make a useable chair, or do we have something more fitting with all that happened in the last two years?
If I ever edit a post it most probably cause of the typos. I make a hell lot of them when I write.

myzmar
Gold Lifer
 
Posts: 998
Joined: Tue Feb 04, 2003 9:52 am
Location: Warsaw, Poland (GMT +1 or +2, depends :)

PostAuthor: JollyOrc » Thu Sep 16, 2004 7:42 am

myzmar wrote:Ok, total n00b as regards scripting here. Should I use this script when I make a useable chair, or do we have something more fitting with all that happened in the last two years?


indeed.

head over to the housing info thread. There you can download a nice package with a lot of scripts fit for player housing. there's one called sitdown, which does the desires effect :)
User avatar
JollyOrc
QA Resource
 
Posts: 3900
Joined: Fri Jan 17, 2003 11:41 am
Location: Germany
Timezone: GMT+1

PostAuthor: myzmar » Thu Sep 16, 2004 7:44 am

JollyOrc wrote:head over to the housing info thread. There you can download a nice package with a lot of scripts fit for player housing. there's one called sitdown, which does the desires effect :)


thanks!
If I ever edit a post it most probably cause of the typos. I make a hell lot of them when I write.

myzmar
Gold Lifer
 
Posts: 998
Joined: Tue Feb 04, 2003 9:52 am
Location: Warsaw, Poland (GMT +1 or +2, depends :)

PostAuthor: Wyrmwing » Thu Sep 16, 2004 8:10 am

IIRC, there's a standard bioware script now that does the same.. somewhere in the x2_.. pile.
Sadako Sasaki wrote:I will write peace on your wings, and you will fly all over the world.

Wyrmwing
Team Member; Retired with Honors
 
Posts: 5830
Joined: Mon Aug 25, 2003 6:41 pm
Location: Croissant Country

PostAuthor: Sindol » Thu Sep 16, 2004 9:19 am

Most CEP chairs already have a sitdown script attached. That is a CEP script and can be found in their hakpaks, but it does basically the same as the Avlis script. So if you need an example on how to set up a chair, just have a look at the existing chairs in the CEP repetoire.
So much fun,
yet so little time to enjoy it.
- Sindol
User avatar
Sindol
Team Member; Retired with Honors
 
Posts: 6487
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)

PostAuthor: KaiRal Windspar » Thu Sep 16, 2004 9:25 am

What about for chairs that are not for bipeds?

Is there a script for 'sit on floor' that can be used for mats and cushion piles and such?
User avatar
KaiRal Windspar
Elder Sage
 
Posts: 3638
Joined: Fri Jun 11, 2004 5:36 am
Location: Seattle


Return to NWN Scripting

Who is online

Registered users: Google [Bot], Vichan Lyonsen