Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype scoreboard, still a few more things to seperate out before … #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pages/gens/image-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ <h1 class="main-title">Image to JSON Text</h1>
<input type="radio" id="hologramChoice"
name="contact" value="hollowgram">
<label for="hologramChoice">Hollowgram</label>
<br>
<input type="radio" id="scoreboardChoice"
name="contact" value="scoreboard">
<label for="scoreboardChoice">Scoreboard/Team Sidebar</label>
</div><br>
<input type="file" id="myFile" hidden="hidden"></input>
<button class = "button" type="button" id="uploadFile">Choose A File</button>
Expand Down
72 changes: 62 additions & 10 deletions pages/js/image-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,28 @@ function extract_data(imageData,ele,startpt) {
}

function getCode() {
if(document.getElementById("tellrawChoice").checked) {
area.value = 'tellraw @s [' + extract_data(imageData,imageData.length,0) + ']';
} else {
const tellrawChoiceChecked = document.getElementById("tellrawChoice").checked
const hologramChoiceChecked = document.getElementById("hologramChoice").checked
const scoreboardChoiceCecked = document.getElementById("scoreboardChoice").checked

if(tellrawChoiceChecked) {
area.value = 'tellraw @s [' + extract_data(imageData,imageData.length,0) + ']';
} else if (hologramChoiceChecked) {
area.value = '#list of summon entities';
for(var i = 0; i < nh; i++) {
area.value = area.value.concat('\nsummon area_effect_cloud ~ ~'+ ((nh - i)*0.225) +' ~ {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["cw_hologram","'+myname +'"],CustomNameVisible:1b,CustomName:\'[' + extract_data(imageData,nh*4,i*nh*4) + ']\'}');
}
} else if (scoreboardChoiceCecked) {
/*
for(let width = 46; width > 0; width--) {
for(let height = 15; height > 0; height--) {
area.value = area.value.concat(`team modify videosuffix`)
}
}
*/
}
download(area.value,'export','.txt');

download(area.value,'export','.txt'); //
}

function copy_text() {
Expand Down Expand Up @@ -132,27 +145,66 @@ function getExtension(filename) {
}

function processVideo(path,e,dur) {
const tellrawChoiceChecked = document.getElementById("tellrawChoice").checked
const hologramChoiceChecked = document.getElementById("hologramChoice").checked
const scoreboardChoiceCecked = document.getElementById("scoreboardChoice").checked

nw = document.getElementById("width").value;
nh = document.getElementById("height").value;
fps = document.getElementById('fps').value;
counter.textContent = Math.floor(dur*fps);
if(document.getElementById("tellrawChoice").checked) {
area.value = "scoreboard players add @s cw_images 1\nscoreboard players set @s[scores={cw_images="+Math.floor(dur*fps)+"..}] cw_images 0";
} else {

if(tellrawChoiceChecked) {
area.value = "scoreboard players add @s cw_images 1\nscoreboard players set @s[scores={cw_images="+Math.floor(dur*fps)+"..}] cw_images 0";
} else if(hologramChoiceChecked) {
area.value = "scoreboard players add "+myname+" cw_images 1\nexecute if score "+myname+" cw_images matches "+Math.floor(dur*fps)+".. run scoreboard players set "+myname+" cw_images 0";

} else if(scoreboardChoiceCecked) {
area.value = area.value.concat(
'team add video','\n',
'team add videosuffix0','\n',
'team add videosuffix1','\n',
'team add videosuffix2','\n',
'team add videosuffix3','\n',
'team add videosuffix4','\n',
'team add videosuffix5','\n',
'team add videosuffix6','\n',
'team add videosuffix7','\n',
'team add videosuffix8','\n',
'team add videosuffix9','\n',
'team add videosuffix10','\n',
'team add videosuffix11','\n',
'team add videosuffix12','\n',
'team add videosuffix13','\n',
'team add videosuffix14','\n',
'team add videosuffix15','\n' //Unused currrently but perhaps looking up and down could change height given our the 15 restricted players in a scoreboard sidebar.
)
}

for(var i = 1; i < Math.floor(dur*fps) + 1; i++) {
var k = i/fps;
getVideoImageAsArray(path,k,vidDone);
}
}
function vidDone(imageData,e,vidDur,pp) {
if(document.getElementById("tellrawChoice").checked) {
area.value = area.value.concat('\nexecute if score @s cw_images matches '+ pp + ' run tellraw @s [' + extract_data(imageData,imageData.length,0) + ']');
} else {
const tellrawChoiceChecked = document.getElementById("tellrawChoice").checked
const hologramChoiceChecked = document.getElementById("hologramChoice").checked
const scoreboardChoiceCecked = document.getElementById("scoreboardChoice").checked

if(tellrawChoiceChecked) {
area.value = area.value.concat('\nexecute if score @s cw_images matches '+ pp + ' run tellraw @s [' + extract_data(imageData,imageData.length,0) + ']');
} else if (hologramChoiceChecked) {
for(var i = 0; i < nh; i++) {
area.value = area.value.concat('\nexecute if score '+myname +' cw_images matches '+ pp + ' run summon area_effect_cloud ~ ~'+ ((nh - i)*0.225) +' ~ {Age:-2147483648,Duration:-1,WaitTime:-2147483648,Tags:["cw_hologram","'+myname +'"],CustomNameVisible:1b,CustomName:\'[' + extract_data(imageData,nh*4,i*nh*4) + ']\'}');
}
} else if (scoreboardChoiceCecked) {
for(var i = 0; i < nh; i++) {
area.value = area.value.concat(
'\n',
`execute if score ${myname} cw_images matches ${pp} run team modify videosuffix${i} suffix [${extract_data(imageData,nh*4,i*nh*4)}]`
)
}

}
counter.textContent = parseInt(counter.textContent) - 1;
if(parseInt(counter.textContent) == 0) {
Expand Down