Sign up
Login
New
Trending
Archive
English
English
Sign up
Login
New Paste
Add Image
-- 1. Correct Library Path (Matches your working Scatman script) local dfpwm = require("cc.audio.dfpwm") -- 2. Correct Peripheral Names (Matched to your specific 'Found these' list) local speaker = peripheral.find("speaker") local detector = peripheral.find("player_detector") -- FIXED: Added underscore -- Configuration local audioFile = "/disk/AMERICA.dfpwm" local detectionRange = 10 local cooldownSeconds = 135 -- 2 minutes, 15 seconds -- Safety check if not speaker or not detector then error("Peripheral Error! Make sure the Speaker and Player Detector are attached.") end local function playSong(triggerSource) local decoder = dfpwm.make_decoder() local file = io.open(audioFile, "rb") if not file then print("Error: Could not find " .. audioFile) return end term.clear() term.setCursorPos(1,1) print("--- PATRIOTIC DEFENSE SYSTEM ---") print("Detected: " .. triggerSource) print("Playing: AMERICA.dfpwm") print("Cooldown active: 2:15") -- Your working 8kb chunk logic while true do local chunk = file:read(8 * 1024) if not chunk then break end local buffer = decoder(chunk) while not speaker.playAudio(buffer) do os.pullEvent("speaker_audio_empty") end end file:close() -- Wait for the 2:15 cooldown to ensure no overlap sleep(cooldownSeconds) term.clear() term.setCursorPos(1,1) print("System Ready. Waiting for players or redstone...") end -- Main Loop term.clear() term.setCursorPos(1,1) print("System Online. Monitoring triggers...") while true do local triggerFound = false local sourceName = "" -- 1. Check Player Detector -- Using 'getPlayersInRange' which returns a list of players local players = detector.getPlayersInRange(detectionRange) if #players > 0 then sourceName = players[1] -- Use the first player's name triggerFound = true -- 2. Check Redstone at the back elseif rs.getInput("back") then sourceName = "Redstone Signal" triggerFound = true end if triggerFound then playSong(sourceName) end sleep(0.5) -- Safety sleep end
Settings
Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English