Table Misc
-Functions that don't fit in the other modules.
-- -
- - -Functions
-HasLineOfSight(room1, pos1, pos2) | -Determine if there's a line of sight between two points. | -
Vibrate(strength, time) | -Vibrate game controller, if function is available and setting is on. | -
FadeOut(speed) | -Do a full-screen fade-to-black. | -
FadeIn(speed) | -Do a full-screen fade-in from black. | -
SetCineBars(height, speed) | -Move black cinematic bars in from the top and bottom of the game window. | -
SetFOV(angle) | -Set field of view. | -
GetCameraType() | -Shows the mode of the game camera. | -
PlayAudioTrack(name, type) | -Play an audio track | -
SetAmbientTrack(name) | -Set and play an ambient track | -
StopAudioTracks() | -Stop any audio tracks currently playing | -
StopAudioTrack(type) | -Stop audio track that is currently playing | -
GetAudioTrackLoudness(type) | -Get current loudness level for specified track type | -
GetCurrentSubtitle() | -Get current subtitle string for a voice track currently playing. | -
PlaySound(sound[, position]) | -Play sound effect | -
IsSoundPlaying(Sound) | -Check if the sound effect is playing | -
IsAudioTrackPlaying(Track) | -Check if the audio track is playing | -
FlipMap(flipmap) | -Do FlipMap with specific ID | -
PlayFlyBy(flyby) | -Enable FlyBy with specific ID | -
CalculateDistance(posA, posB) | -Calculate the distance between two positions. | -
CalculateHorizontalDistance(posA, posB) | -Calculate the horizontal distance between two positions. | -
PercentToScreen(x, y) | -Translate a pair of percentages to screen-space pixel coordinates. | -
ScreenToPercent(x, y) | -Translate a pair of coordinates to percentages of window dimensions. | -
ResetObjCamera() | -Reset object camera back to Lara and deactivate object camera. | -
PrintLog(message, logLevel[, allowSpam]) | -Write messages within the Log file | -
Vibrate(strength, time) | -Vibrate gamepad, if possible. | -
KeyIsHeld(action) | -Check if particular action key is held | -
KeyIsHit(action) | -Check if particular action key was hit (once) | -
KeyPush(action) | -Emulate pushing of a certain action key | -
KeyClear(action) | -Clears particular input from action key | -
-
- - -
Functions
- --
-
- - - HasLineOfSight(room1, pos1, pos2) - -
-
- Determine if there's a line of sight between two points.
-
-
i.e. if we run a direct line from one position to another -will any geometry get in the way?
- -Note: if you use this with Moveable:GetPosition to test if (for example) -two creatures can see one another, you might have to do some extra adjustments.
- -This is because the "position" for most objects refers to its base, i.e., the floor. -As a solution, you can increase the y-coordinate of this position to correspond to roughly where the -eyes of the creatures would be. - - - -
Parameters:
--
-
- room1 - float - ID of the room where the first position is - -
- pos1 - Vec3 - first position - -
- pos2 - Vec3 - second position - -
Returns:
--
-
- bool
- is there a direct line of sight between the two positions?
-
Usage:
--
-
local flamePlinthPos = flamePlinth:GetPosition() + Vec3(0, flamePlinthHeight, 0); -print(Misc.HasLineOfSight(enemyHead:GetRoomNumber(), enemyHead:GetPosition(), flamePlinthPos))
- - -
- - - - Vibrate(strength, time) - -
-
- Vibrate game controller, if function is available and setting is on.
-
-
-
-
Parameters:
--
-
- strength - float - Strength of the vibration - -
- time - float - (default 0.3) Time of the vibration, in seconds - -
- - - - FadeOut(speed) - -
-
- Do a full-screen fade-to-black. The screen will remain black until a call to FadeIn.
-
-
-
-
Parameters:
--
-
- speed - float - (default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second. - -
- - - - FadeIn(speed) - -
-
- Do a full-screen fade-in from black.
-
-
-
-
Parameters:
--
-
- speed - float - (default 1.0). Speed in "amount" per second. A value of 1 will make the fade take one second. - -
- - - - SetCineBars(height, speed) - -
-
- Move black cinematic bars in from the top and bottom of the game window.
-
-
-
-
Parameters:
--
-
- height - float - (default 30) Percentage of the screen to be covered - -
- speed - float - (default 30) Coverage percent per second - -
- - - - SetFOV(angle) - -
-
- Set field of view.
-
-
-
-
Parameters:
--
-
- angle - float - in degrees (clamped to [10, 170]) - -
- - - - GetCameraType() - -
-
- Shows the mode of the game camera.
-
-
-
-
-
Returns:
--
-
- CameraType
- value used by the Main Camera.
-
Usage:
--
-
LevelFuncs.OnControlPhase = function() - if (Misc.GetCameraType() == CameraType.Combat) then - --Do your Actions here. - end -end
- - -
- - - - PlayAudioTrack(name, type) - -
-
- Play an audio track
-
-
-
-
Parameters:
--
-
- name - string - of track (without file extension) to play - -
- type - SoundTrackType - of the audio track to play - -
- - - - SetAmbientTrack(name) - -
-
- Set and play an ambient track
-
-
-
-
Parameters:
--
-
- name - string - of track (without file extension) to play - -
- - - - StopAudioTracks() - -
- - Stop any audio tracks currently playing - - - - - - - - - -
- - - StopAudioTrack(type) - -
-
- Stop audio track that is currently playing
-
-
-
-
Parameters:
--
-
- type - SoundTrackType - of the audio track - -
- - - - GetAudioTrackLoudness(type) - -
-
- Get current loudness level for specified track type
-
-
-
-
Parameters:
--
-
- type - SoundTrackType - of the audio track - -
Returns:
--
-
- float
- current loudness of a specified audio track
-
- - - - GetCurrentSubtitle() - -
-
- Get current subtitle string for a voice track currently playing.
-Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track.
-Returns nil if no voice track is playing or no subtitle present.
-
-
-
-
-
Returns:
--
-
- string
- current subtitle string
-
- - - - PlaySound(sound[, position]) - -
-
- Play sound effect
-
-
-
-
Parameters:
--
-
- sound - int - ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window. - -
- position - Vec3 - The 3D position of the sound, i.e. where the sound "comes from". If not given, the sound will not be positional. - (optional) - -
- - - - IsSoundPlaying(Sound) - -
-
- Check if the sound effect is playing
-
-
-
-
Parameters:
--
-
- Sound - int - ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window. - -
- - - - IsAudioTrackPlaying(Track) - -
-
- Check if the audio track is playing
-
-
-
-
Parameters:
--
-
- Track - string - filename to check. Should be without extension and without full directory path. - -
- - - - FlipMap(flipmap) - -
-
- Do FlipMap with specific ID
-
-
-
-
Parameters:
--
-
- flipmap - int - (ID of flipmap) - -
- - - - PlayFlyBy(flyby) - -
-
- Enable FlyBy with specific ID
-
-
-
-
Parameters:
--
-
- flyby - short - (ID of flyby) - -
- - - - CalculateDistance(posA, posB) - -
-
- Calculate the distance between two positions.
-
-
-
-
Parameters:
- - -Returns:
--
-
- int
- the direct distance from one position to the other
-
- - - - CalculateHorizontalDistance(posA, posB) - -
-
- Calculate the horizontal distance between two positions.
-
-
-
-
Parameters:
- - -Returns:
--
-
- int
- the direct distance on the XZ plane from one position to the other
-
- - - - PercentToScreen(x, y) - -
-
- Translate a pair of percentages to screen-space pixel coordinates.
-To be used with Strings.DisplayString:SetPosition and Strings.DisplayString.
-
-
-
-
Parameters:
--
-
- x - float - percent value to translate to x-coordinate - -
- y - float - percent value to translate to y-coordinate - -
Returns:
--
-
- - int - x coordinate in pixels -
- - int - y coordinate in pixels -
Usage:
--
-
local halfwayX, halfwayY = PercentToScreen(50, 50) -local baddy -local spawnLocationNullmesh = GetMoveableByName("position_behind_left_pillar") -local str1 = DisplayString("You spawned a baddy!", halfwayX, halfwayY, Color(255, 100, 100), false, {DisplayStringOption.SHADOW, DisplayStringOption.CENTER}) - -LevelFuncs.triggerOne = function(obj) - ShowString(str1, 4) -end
- - -
- - - - ScreenToPercent(x, y) - -
-
- Translate a pair of coordinates to percentages of window dimensions.
-To be used with Strings.DisplayString:GetPosition.
-
-
-
-
Parameters:
--
-
- x - int - pixel value to translate to a percentage of the window width - -
- y - int - pixel value to translate to a percentage of the window height - -
Returns:
--
-
- - float - x coordinate as percentage -
- - float - y coordinate as percentage -
- - - - ResetObjCamera() - -
- - Reset object camera back to Lara and deactivate object camera. - - - - - - - - - -
- - - PrintLog(message, logLevel[, allowSpam]) - -
-
- Write messages within the Log file
-
-
For native Lua handling of errors, see the official Lua website:
- - - - - - -Parameters:
--
-
- message - string - to be displayed within the Log - -
- logLevel - LogLevel - log level to be displayed - -
- allowSpam - bool - true allows spamming of the message - (optional) - -
Usage:
--
-
PrintLog('test info log', LogLevel.INFO) -PrintLog('test warning log', LogLevel.WARNING) -PrintLog('test error log', LogLevel.ERROR) --- spammed message -PrintLog('test spam log', LogLevel.INFO, true)
- - -
- - - - Vibrate(strength, time) - -
-
- Vibrate gamepad, if possible.
-
-
-
-
Parameters:
--
-
- strength - float - - - - -
- time - float - (in seconds, default: 0.3) - -
- - - - KeyIsHeld(action) - -
-
- Check if particular action key is held
-
-
-
-
Parameters:
--
-
- action - ActionID - action mapping index to check - -
- - - - KeyIsHit(action) - -
-
- Check if particular action key was hit (once)
-
-
-
-
Parameters:
--
-
- action - ActionID - action mapping index to check - -
- - - - KeyPush(action) - -
-
- Emulate pushing of a certain action key
-
-
-
-
Parameters:
--
-
- action - ActionID - action mapping index to push - -
- - - - KeyClear(action) - -
-
- Clears particular input from action key
-
-
-
-
Parameters:
--
-
- action - ActionID - action mapping index to clear - -
-