Search This Blog

Wednesday, September 26, 2018

New Lua Commands since 5/12/2017


So recently I’ve found myself back in Game-Guru for more significant lengths of time than I’ve had in a while.  Up to this point I’ve mostly been relegated to occasionally dipping my toes in the water while things are updating at a furious pace due to github contributions. 
So I found myself troubleshooting some of my weather system functions and realized there was a significant body of added functions since the last major version (5.12.2017/DX9).
The DX9 edition was fairly stable, so a lot of people use it – however since then a large amount of updated Lua commands have been added with no real clear list of what’s been changed between now and then.  So without any further fanfare, here’s a simple list capturing most of the changes listed on github.  They were obtained by checking the history of changes on github so if I missed any, please let me know.
Most of this is documented in global.lua itself, albeit not as a straight ‘diff’ as this is intended to be.

ENTITY CONTROL

ScaleObject : ScaleObject( obj, x, y, z ) -- Scales object in all axis (Note: uses object id not entity!)
***** The following four functions return multiple values, if you do not need them all just replace
***** the ones you don't need with '_' for example : _, _, _, Ax, Ay, Az = GetEntityPosAng( e ) would
***** just give you last three of the 6 values returned
GetObjectPosAng : x, y, z, Ax, Ay, Az = GetObjectPosAng( obj ) -- returns position and Euler angles of object
GetEntityPosAng : x, y, z, Ax, Ay, Az = GetEntityPosAng( e )   -- returns position and Euler angles of entity
GetObjectColBox : xmin, ymin, zmin, xmax, ymax, zmax = GetObjectCollBox( obj ) -- returns collision cube of object
GetEntityColBox : xmin, ymin, zmin, xmax, ymax, zmax = GetEntityCollBox( e )   -- returns collision cube of entity
Collision box is defined by coordinates of two opposing corners, from these it is easy to calculate the size of the object
GetEntityWeight : weight = GetEntityWeight( e ) -- returns the Physics weight value of the entity
GetObjectScales : xs, ys, zs = GetObjectScales( obj ) -- returns scale values of object in all axis (Note: uses object id not entity!)
SetRotationYSlowly : SetRotationYSlowly(e,destangle,smoothvalue) -- where e is the entity and a smooth value of 100 is immediate, where 50 takes twice as long to rotate to destangle (Dest Angle)
RotateToPlayerWithOffset(e,angleoffset) – Rotates an entity to the player with a euler angle offset.
SetHoverFactor(e,v) – Sets E entity’s hover factor by V value. Presumably used for flying objects.
SetEntityHealthSilent(e,v) – Unsure of actual function but obviously it sets an entity’s health… silently?  Needs testing.


JOYSTICK/GAMEPAD/VR CONTROLS

NOTE: Joystick and VR function before was simply a placeholder.  So these commands were there before but didn’t actually work – now they do, hence their inclusion below.
JoystickX: JoystickX() -- returns a value between -1000 and +1000 representing X axis of controller
JoystickY: JoystickY() -- returns a value between -1000 and +1000 representing Y axis of controller
JoystickZ: JoystickZ() -- returns a value between -1000 and +1000 representing Trigger of controller
PromptLocalForVR(e,str,vrmode) – Unsure, bit it does have actual function now.
PromptLocal(e,str) – some kind of vr related function unfortunately poorly documented for now.
JoystickHatAngle: JoystickHatAngle() -- command used by the default player control mechanism
JoystickFireXL: JoystickFireXL() -- command used by the default player control mechanism
JoystickTwistX: JoystickTwistX() -- command used by the default player control mechanism
JoystickTwistY: JoystickTwistY() -- command used by the default player control mechanism
JoystickTwistZ: JoystickTwistZ() -- command used by the default player control mechanism
SetGamePlayerStatePlrZoomInChange: SetGamePlayerStatePlrZoomInChange() -- command used by the default player control mechanism
GetGamePlayerStatePlrZoomInChange: GetGamePlayerStatePlrZoomInChange() -- command used by the default player control mechanism
GetDynamicCharacterControllerDidJump: x=GetDynamicCharacterControllerDidJump() -- returns 1 if controller jumped

SOUND CONTROL

SetEntityString : SetEntityString ( e, slot, string ) -- where e is the entity number and slot (0-4) to write the string into.  I believe this probably allows you to change sounds or configure them programmatically.
GetEntityString : GetEntityString ( e, slot ) -- where e is the entity number and slot (0-4) is the sound slot index.  The above supposition is confirmed by this.
LoopNon3DSound(e,v) – entity/value.  Loops a slotted sound without 3d, so no distance modifiers just same volume at any distance.

WATER SHADER CONTROLS

**Water Shader Settings*** Look into the shader for informations about these values(open effectbank/reloaded/water_basic.fx with i.e. notepad)
SetWaterHeight(value) – Sets height of water plane.
SetWaterColor(red,green,blue) – Sets RGB of water plane.
SetWaterWaveIntensity(value) – Sets intensity of waves
SetWaterTransparancy(value) – Sets transparency of waves
SetWaterReflection(value) – Sets reflection value of water surface
SetWaterReflectionSparkleIntensity(value) – Specularity of water surface, I believe
SetWaterFlowDirection(x,y,speed) -- small tip: -1 =east/north; 1=west/south - speed is a multiplier of the flowdirection(higher => fast flow)
SetWaterDistortionWaves(value) --  Water noise level
SetRippleWaterSpeed(value) – how fast the ripples move
GetWaterHeight() – returns height of water
GetWaterWaveIntensity() – returns intensity of water
GetWaterShaderColorRed() – returns water plane R value
GetWaterShaderColorGreen() – returns water plane G value
GetWaterShaderColorBlue() --  returns water plane B value
GetWaterTransparancy() – returns water transparency value
GetWaterReflection() --  returns water reflection value
GetWaterReflectionSparkleIntensity() --  Returns ‘water reflection sparkle intensity’ value
GetWaterFlowDirectionX() – returns water flow direction X
GetWaterFlowDirectionY() – returns water flow direction Y
GetWaterFlowSpeed() – returns water flow speed
GetWaterDistortionWaves() – returns water distortion wave setting
GetRippleWaterSpeed() – returns water ripple speed

LIGHT AND SKY CONTROL

SetSkyTo(str) : str=foldername of the sky you want to change to (i.e. ChangeSkyTo("dark"))
GetEntityLightNumber( e ) --  Returns entity light number (HALLELUJAH!)
x, y, z = GetLightPosition( lightNum ) – Presumably returns light XYZ position into 3 separate variables, needs testing.
r, g, b = GetLightRGB( lightNum )  -- Presumably fills RGB values into 3 separate variables.  Needs testing.
GetLightRange( lightNum ) --  Returns light range.
GetLightAngle : xv, yv, zv = GetLightAngle( LightNum ) -- returns the angle vector of the dynamic light specified
SetLightAngle : SetLightAngle( lightNum, xv, yv, zv ) -- sets the angle vector of the specified light ( e.g. 0, 0, 1 would be 'North' or +Z axis )
SetLightPosition( lightNum, x, y, z ) – Lightnum=entity light number.  Sets physical position.
SetLightRGB( lightNum, r, g, b ) --  Lightnum=entity light number.  Sets RBG value of light.
SetLightRange( lightNum, range )   -- range is 1 .. 10000, values outside range are capped; configures output range of light.

FUNCTION FOR FUNCTIONS

SetPreExitValue: SetPreExitValue(e,value) -- where e is the entity and a value of 2 will exit preexit function.  This is invoked at runtime and allows a function to return a value if it exits before being allowed to return a code properly – I think.  Needs testing but most of you won’t be using this unless you took actual programming classes :P

PARTICLE CONTROLS (!)

ParticlesGetFreeEmitter:  iEmitterID = ParticlesGetFreeEmitter() -- returns the index of a free particle emitter object
ParticlesAddEmitter: ParticlesAddEmitter(animationSpeed,startsOffRandomAngle,offsetMinX,offsetMinY,offsetMinZ,offsetMaxX,offsetMaxY,offsetMaxZ,scaleStartMin,scaleStartMax,scaleEndMin,scaleEndMax,movementSpeedMinX,movementSpeedMinY,movementSpeedMinZ,movementSpeedMaxX,movementSpeedMaxY,movementSpeedMaxZ,rotateSpeedMinZ,rotateSpeedMaxZ,lifeMin,lifeMax,alphaStartMin,alphaStartMax,alphaEndMin,alphaEndMax,frequency) -- create a particle emitter under the index iEmitterID and specified parameters (yes, the command really is that long).
ParticleAddEmitterEx: (as above with additional parameters) e, limbindex, particle image ID, particle frame count -- where e is the entity to assign particle to
ParticlesDeleteEmitter: ParticlesDeleteEmitter ( iEmitterID ) -- delete a particle emitter under index iEmitterID
ParticleAddEmitterEx: (as above with additional parameters) e, limbindex, particle image ID, particle frame count -- where e is the entity to assign particle to



DECOMMED AI CONTROLS

Lastly, a large amount of OLD AI commands were decommissioned.  This means new ones are likely on the way with the updated AI changes in the pipeline.
CharacterControlManual(e) – decommed
CharacterControlLimbo(e) – decommed
CharacterControlUnarmed(e) – decommed
CharacterControlArmed(e) – decommed
CharacterControlFidget(e) – decommed
CharacterControlDucked(e) – decommed
CharacterControlStand(e) – decommed
SetCharacterToWalk(e) – decommed
SetCharacterToRun(e) – decommed
SetCharacterToStrafeLeft(e) – decommed
SetCharacterToStrafeRight(e) – decommed
SetCharacterVisionDelay(e,v) – decommed
LockCharacterPosition(e,v) – decommed
UnlockCharacterPosition(e,v) – decommed

No comments: