0%

Client interface api object

api control interface, obtained from the sf_start parameter of the client entry module ClientMain.lua

  1. api.Constants.*** Required constant-on table, such as keyboard code and touch type TOUCH_*, please check the constant-on description file [Constants] for details
  2. Audio engine, more functions can be added upon request
    1. api.playOnce(path,cb) -> Play the sound effect once, path: the relative path of the audio event, no extension is required. Finally, the audio directory needs to be packaged into dat format through the project. cb -> callback method, this method will be called back after each playback is completed
    2. api.playOnce(path,pan) -> Play the sound effect once, path: the relative path of the audio event, no extension is required, and finally the audio directory needs to be packaged into dat format through the project. pan -> 2d panning position, from -1.0 to 1.0, from left channel to right channel.
    3. api.playOwn(name,path) -> Play the audio and give the audio a name. You can then control the audio through the name. Audio with the same name is mutually exclusive. For example, playback will interrupt the previous sound.
    4. api.playWithPosition(path,x,y,z) -> Play the sound effect once, according to the position, path: the relative path of the audio event, no extension is needed, and finally the audio directory needs to be packaged into dat format through the project. x, y, z coordinates of the audio sound source in the 3D environment, accurate to the decimal point. x left and right, y up and down, z front and back.
    5. api.stopAudio(name) -> Stop audio, but do not release it in memory.
    6. api.releaseAudio(name) -> Stop and release audio
    7. api.getGain(name) -> Get the audio volume, parameter name-> Get the name of the audio volume, return value volume, 0.0 to 1.0.
    8. api.setGain(name,g) -> Set the audio volume, name is the name of the sound effect, and is the first parameter of playOwn; g -> Volume, 0.0 to 1.0.
    9. api.getPitch(name) -> Get the audio pitch, parameter name-> audio name, return value audio pitch, 1.0 is normal, the value range is 0 ~ 100
    10. api.setPitch(name,p) -> Set the audio frequency, name is the name of the sound effect; p -> Set the pitch, the value range is 0 ~ 100
    11. api.setPan(name,p) -> Set the left and right panning of the audio, name is the name of the sound effect; p 2d panning position, from -1.0 to 1.0, from the left channel to the right channel.
    12. api.setPosition(name,pos) -> Set the sound source coordinates of the 3D sound effect in the 3D environment, name is the name of the sound effect; pos coordinate table, for example {x=1.3,y=0,z=8.32}
    13. api.getTimeline(name) -> Get the current playback timeline, parameter name-> audio name, return value current timeline, millisecond unit.
    14. api.setTimeline(name,t) -> Set the current audio timeline, name is the name of the sound effect; t -> Timeline, in milliseconds.
    15. api.getPaused(name) -> Get whether the audio playback is paused. The return value true indicates that the audio is currently paused. The audio must be in the playing state to determine whether it is paused. For the audio playback status, refer to 13.
    16. api.setPaused(name,p) -> Set audio pause. name > audio name, p is true to pause, false is to continue playing.
    17. api.getPlayState(name) -> Get the audio playback status, name > audio name, return value, audio playback status: as follows:
      0 -> Now playing
      1 -> The timeline cursor is paused on a sustain point. Advanced function, pause is located at a time point you specify.
      2 -> Stop playing.
      3 -> Loaded into memory, initializing, ready to play.
      4 -> Preparing to stop playback.
    18. api.getProperty(name,flag) -> Get the audio built-in properties, name> audio name; flag > the type of built-in properties to be obtained, refer to 15.
    19. api.setProperty(name,flag,value) -> Set the audio built-in properties, name>Audio name; flag>Please refer to the following for the types of built-in properties to be obtained; value>The specific value of the built-in properties
      0 -> Audio priority, default -1, value range -1~256, the higher the priority, it will not become virtual audio
      1 -> Plan delay in DSP clock units, default value is -1. Range: -1, [0, inf) Default: -1
      2 -> Plan to look forward on the timeline in units of DSP clocks, default is -1. Range: -1, [0, inf) Default: -1
      3 -> Override the event’s 3D minimum distance, or -1 for default.Range: -1, [0, inf) Default: -1 Units: Distance units
      4 -> Override the event’s 3D maximum distance, or -1 for default.Range: -1, [0, inf) Default: -1 Units: Distance units
      5 -> Cooldown time, Override the event’s cooldown, or -1 for default.Range: -1, [0, inf) Default: -1
      6 -> The maximum number of event attribute types at the same time.
    20. api.setListenerPosition(pos) -> Set the coordinates of the listener in the 3D environment; pos coordinate table, for example {x=1.3,y=0,z=8.32}
    21. api.setListenerVelocity(vel) -> Set the propagation speed of the listener’s sound in the 3D environment. The default is {x=0, y=0, z=0}. This parameter controls the sound waves heard by the listener in the environment. Doppler effect, no Doppler effect by default
    22. api.setListenerForward(f) -> Set the facing direction of the listener; f is the coordinate table of the facing direction, for example, facing to the left {x=-1,y=0,z=0}
    23. api.setListenerUp(up) -> Set the listener’s deviation; up deviation coordinate table, for example: {x=0,y=0.5,z=0}
    24. api.getListenerPosition() -> Get the coordinates of the listener in the 3D environment; return the listener coordinates coordinate table, for example {x=1.3,y=0,z=8.32}
    25. api.getListenerVelocity() -> Get the listener’s velocity in 3D. return Returns the listener speed table
    26. getListenerForward() -> Get the direction of the listener in 3D. return returns the listener facing the table
    27. api.getListenerUp() -> Get the listener’s deviation in 3D. return Returns the audience deviation table
    28. api.getParameter(name,key) -> Get the parameters of the event strength discussed with the sound effect engineer, name is the name of the sound effect strength to be obtained, key parameter name
      28 api.setParameter(name,key,value) -> Set the parameter variables in the sound effect engine and defined by the sound effect engineer, name is the sound effect strength name; key is the parameter name; value is the parameter value, type number
    29. api.setParameterLabel(name,key,label) -> Set the enumeration parameter variable in the sound effect engine and defined by the sound effect engineer, name is the name of the sound effect strength; key is the parameter name; label is the string enumeration name, type string
  3. Voice library engine
    1. api.speak(text,appended) -> Offline TTS reading, text reading text UTF8, whether appended needs to be queued for reading, the default parameter is omitted to interrupt the reading
    2. api.speakOnline(text,appended) -> Online TTS reading, text reading text UTF8, whether appended needs to be queued for reading, the default parameter is omitted to interrupt the reading, the reading will not interrupt the local offline TTS, generally used for notification class reading .
  4. Transmission engine
    1. api.send(t) -> Send data to the server t is lua table
  5. Timer
    1. api.addTimer(ms,cb) -> Add timer, parameter ms milliseconds, cb callback function, the callback method returns true and the timer continues, returns false and the timer ends, return returns the method to cancel the current timer
    2. api.time() -> Get the return value as a decimal in seconds, accurate to milliseconds
  6. Controlling the microphone cannot be used in global games.
    1. api.muteMic(b) -> if b is true, the microphone is muted, and if false, the microphone is unmuted.
    2. api.isMuteMic() -> return returns whether the microphone is muted, true means muted.
  7. Modify touch mode
    1. api.selectGestureMode(mode) -> Parameter mode, 1 normal mode, full screen touch, 2 upper and lower split screen mode, at this time the touches on both sides will not interfere with each other and can respond.
    2. Event response. After selecting split-screen mode, there is one more parameter in all touch event response methods. After fingers, it is gid. A gid of 200 means it is in the upper half of the screen. A gid of 300 means it is in the lower half of the screen. When in full screen touch mode gid is 100.
  8. Other functions
    1. api.copy(appended) -> Copy the content just read aloud using tts, appended is true to indicate additional copy
    2. api.vibrate(index,low,high,ms) -> vibrate the game controller, index: the index ID of the controller handle; low: the vibration rate of the dropper bottle, high: the vibration rate of the high-level vibration, the rate is from Starting from 0 to 0xFFFF is the maximum; ms: the duration of vibration, in milliseconds.
    3. api.moveMouse(x,y) -> Move the mouse pointer to the heart position.