SC CODE: // Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "effects.js")
31 STORE("descrHdr", "Effects JS file")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "effects.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "1737c585645d608af2b09edef4726ddedf7c3c5b3dbd0c0991b0c68c5bbff3e0")
37 STORE("fileCheckS", "1219bd01ba77f9bf7d8f8057400b5bb9f4efda73fe9334dd21c8a29ff10a4b73")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*// Effects
function spawnParticles(x, y, count = 10) {
for (let i = 0; i < count; i++) {
game.particles.push({
x, y,
vx: (Math.random() - 0.5) * 0.4,
vy: (Math.random() - 0.5) * 0.4,
life: 300 + Math.random() * 200,
color:"orange",
size:2
});
}
}
function spawnFireworks(x, y, count = 40) {
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI * 2;
const speed = 2 + Math.random() * 4;
game.particles.push({
x,
y,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed,
life: 40 + Math.random() * 20,
size: 3 + Math.random() * 3,
color: `hsl(${Math.random() * 360}, 80%, 60%)`
});
}
}
// Audio
let volume = .5;
let audioCtx;
function initAudio() {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
function sfxGun() {
const ctx = audioCtx;
const o = ctx.createOscillator();
const g = ctx.createGain();
o.type = "square";
o.frequency.setValueAtTime(600, ctx.currentTime);
o.frequency.exponentialRampToValueAtTime(80, ctx.currentTime + 0.1);
g.gain.setValueAtTime(volume, ctx.currentTime);
g.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.1);
o.connect(g).connect(ctx.destination);
o.start();
o.stop(ctx.currentTime + 0.1);
}
function sfxExplosion() {
const ctx = audioCtx;
const buffer = ctx.createBuffer(1, 44100, 44100);
const data = buffer.getChannelData(0);
for (let i = 0; i < data.length; i++) {
data[i] = (Math.random() * 2 - 1) * (1 - i / data.length);
}
const noise = ctx.createBufferSource();
noise.buffer = buffer;
const g = ctx.createGain();
g.gain.setValueAtTime(volume, ctx.currentTime);
g.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + 0.5);
noise.connect(g).connect(ctx.destination);
noise.start();
}*/ |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "effects.js")
31 STORE("descrHdr", "Effects JS file")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "effects.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "1737c585645d608af2b09edef4726ddedf7c3c5b3dbd0c0991b0c68c5bbff3e0")
37 STORE("fileCheckS", "1219bd01ba77f9bf7d8f8057400b5bb9f4efda73fe9334dd21c8a29ff10a4b73")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*// Effects
function spawnParticles(x, y, count = 10) {
for (let i = 0; i < count; i++) {
game.particles.push({
x, y,
vx: (Math.random() - 0.5) * 0.4,
vy: (Math.random() - 0.5) * 0.4,
life: 300 + Math.random() * 200,
color:"orange",
size:2
});
}
}
function spawnFireworks(x, y, count = 40) {
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI * 2;
const speed = 2 + Math.random() * 4;
game.particles.push({
x,
y,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed,
life: 40 + Math.random() * 20,
size: 3 + Math.random() * 3,
color: `hsl(${Math.random() * 360}, 80%, 60%)`
});
}
}
// Audio
let volume = .5;
let audioCtx;
function initAudio() {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
function sfxGun() {
const ctx = audioCtx;
const o = ctx.createOscillator();
const g = ctx.createGain();
o.type = "square";
o.frequency.setValueAtTime(600, ctx.currentTime);
o.frequency.exponentialRampToValueAtTime(80, ctx.currentTime + 0.1);
g.gain.setValueAtTime(volume, ctx.currentTime);
g.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.1);
o.connect(g).connect(ctx.destination);
o.start();
o.stop(ctx.currentTime + 0.1);
}
function sfxExplosion() {
const ctx = audioCtx;
const buffer = ctx.createBuffer(1, 44100, 44100);
const data = buffer.getChannelData(0);
for (let i = 0; i < data.length; i++) {
data[i] = (Math.random() * 2 - 1) * (1 - i / data.length);
}
const noise = ctx.createBufferSource();
noise.buffer = buffer;
const g = ctx.createGain();
g.gain.setValueAtTime(volume, ctx.currentTime);
g.gain.exponentialRampToValueAtTime(0.01, ctx.currentTime + 0.5);
noise.connect(g).connect(ctx.destination);
noise.start();
}*/'] |