Package openmw.selfΒΆ
openmw.self
provides full access to the object the script is attached to.
Can be used only from local scripts. All fields and function of GameObject
are also available for openmw.self
.
Usage:
local self = require('openmw.self')
local types = require('openmw.types')
if self.type == types.Player then -- All fields and functions of `GameObject` are available.
self:sendEvent("something", self.position)
end
Type self
self.controls |
Movement controls (only for actors) |
self:enableAI(v) |
Enables or disables standard AI (enabled by default). |
self:isActive() |
Returns true if the script isActive (the object it is attached to is in an active cell). |
self.mwscript |
Local variables of an mwscript on this object (nil if there is no mwscript) |
self.object |
The object the script is attached to (readonly) |
self.ownerFactionId |
Faction who owns the object or |
self.ownerFactionRank |
Rank required to be allowed to pick up the object (mutable). |
self.ownerRecordId |
NPC who owns the object or |
Type ActorControls
ActorControls.jump |
If true - initiate a jump |
ActorControls.movement |
+1 - move forward, -1 - move backward |
ActorControls.pitchChange |
Look down (radians); if negative - look up |
ActorControls.run |
true - run, false - walk |
ActorControls.sideMovement |
+1 - move right, -1 - move left |
ActorControls.sneak |
If true - sneak |
ActorControls.use |
if 1 - activates the readied weapon/spell. For weapons, keeping at 1 will charge the attack until set to 0. |
ActorControls.yawChange |
Turn right (radians); if negative - turn left |
Type self
Extends openmw.core#GameObject
Field(s)
- #ActorControls self.controls
-
Movement controls (only for actors)
- self:enableAI(v)
-
Enables or disables standard AI (enabled by default).
Parameter
-
#boolean v
:
-
- self:isActive()
-
Returns true if the script isActive (the object it is attached to is in an active cell).
If it is not active, then
openmw.nearby
can not be used.Return value
#boolean:
- #MWScriptVariables self.mwscript
-
Local variables of an mwscript on this object (nil if there is no mwscript)
Usages:
if self.mwscript then ... end -- check if there is an mwscript on this object
tostring(self.mwscript) -- name of the script
-- print value of local variable 'something' (0 if there is no such variable) print(self.mwscript.something)
-- set local variable 'something' (raises an error if there is no such variable) self.mwscript.something = 5
- openmw.core#GameObject self.object
-
The object the script is attached to (readonly)
- #string self.ownerFactionId
-
Faction who owns the object or
nil
(mutable).
- #number self.ownerFactionRank
-
Rank required to be allowed to pick up the object (mutable).
- #string self.ownerRecordId
-
NPC who owns the object or
nil
(mutable).
Type ActorControls
Allows to view and/or modify controls of an actor.
All fields are mutable.
Field(s)
- #boolean ActorControls.jump
-
If true - initiate a jump
- #number ActorControls.movement
-
+1 - move forward, -1 - move backward
- #number ActorControls.pitchChange
-
Look down (radians); if negative - look up
- #boolean ActorControls.run
-
true - run, false - walk
- #number ActorControls.sideMovement
-
+1 - move right, -1 - move left
- #boolean ActorControls.sneak
-
If true - sneak
- #number ActorControls.use
-
if 1 - activates the readied weapon/spell. For weapons, keeping at 1 will charge the attack until set to 0.
- #number ActorControls.yawChange
-
Turn right (radians); if negative - turn left