mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 00:16:27 +02:00
Test beep boops
This commit is contained in:
@@ -197,7 +197,7 @@ function RADAR:SetSettingValue( setting, value )
|
|||||||
if ( value ~= nil ) then
|
if ( value ~= nil ) then
|
||||||
self.vars.settings[setting] = value
|
self.vars.settings[setting] = value
|
||||||
|
|
||||||
if ( value == "same" or value == "opp" ) then
|
if ( setting == "same" or setting == "opp" ) then
|
||||||
self:UpdateRayEndCoords()
|
self:UpdateRayEndCoords()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -479,7 +479,7 @@ end
|
|||||||
|
|
||||||
function RADAR:UpdateRayEndCoords()
|
function RADAR:UpdateRayEndCoords()
|
||||||
for k, v in pairs( self.rayTraces ) do
|
for k, v in pairs( self.rayTraces ) do
|
||||||
local endY = ( self:GetSettingValue( v.rayType ) * 0.2 ) * v.endVec.y
|
local endY = ( self:GetSettingValue( v.rayType ) * 0.2 ) * v.endVec.baseY
|
||||||
v.endVec.y = endY
|
v.endVec.y = endY
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -818,6 +818,7 @@ RegisterNUICallback( "setAntennaMode", function( data )
|
|||||||
else
|
else
|
||||||
RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function()
|
RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function()
|
||||||
SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } )
|
SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } )
|
||||||
|
SendNUIMessage( { _type = "audio", name = "beep" } )
|
||||||
end )
|
end )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
@@ -828,6 +829,7 @@ RegisterNUICallback( "toggleAntenna", function( data )
|
|||||||
else
|
else
|
||||||
RADAR:ToggleAntenna( data.value, function()
|
RADAR:ToggleAntenna( data.value, function()
|
||||||
SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } )
|
SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } )
|
||||||
|
SendNUIMessage( { _type = "audio", name = RADAR:IsAntennaTransmitting( data.value ) and "xmit_on" or "xmit_off" } )
|
||||||
end )
|
end )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|||||||
BIN
nui/beep.ogg
Normal file
BIN
nui/beep.ogg
Normal file
Binary file not shown.
16
nui/radar.js
16
nui/radar.js
@@ -11,6 +11,13 @@
|
|||||||
// Variables
|
// Variables
|
||||||
var resourceName;
|
var resourceName;
|
||||||
|
|
||||||
|
const audioNames =
|
||||||
|
{
|
||||||
|
beep: "beep.ogg",
|
||||||
|
xmit_on: "xmit_on.ogg",
|
||||||
|
xmit_off: "xmit_off.ogg",
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the main const element structure, this way we can easily access elements without having the mess
|
// Setup the main const element structure, this way we can easily access elements without having the mess
|
||||||
// that was in the JS file for WraithRS
|
// that was in the JS file for WraithRS
|
||||||
const elements =
|
const elements =
|
||||||
@@ -299,6 +306,12 @@ function settingUpdate( ants, fast )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function playAudio( name )
|
||||||
|
{
|
||||||
|
let audio = new Audio( audioNames[name] );
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
|
|
||||||
// This function is used to send data back through to the LUA side
|
// This function is used to send data back through to the LUA side
|
||||||
function sendData( name, data ) {
|
function sendData( name, data ) {
|
||||||
$.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) {
|
$.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) {
|
||||||
@@ -365,6 +378,9 @@ window.addEventListener( "message", function( event ) {
|
|||||||
case "settingUpdate":
|
case "settingUpdate":
|
||||||
settingUpdate( item.antennaData, item.fast );
|
settingUpdate( item.antennaData, item.fast );
|
||||||
break;
|
break;
|
||||||
|
case "audio":
|
||||||
|
playAudio( item.name );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
nui/xmit_off.ogg
Normal file
BIN
nui/xmit_off.ogg
Normal file
Binary file not shown.
BIN
nui/xmit_on.ogg
Normal file
BIN
nui/xmit_on.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user