Home › Forums › General Questions › How to reference a Verge 3d varible in a Javascript Code Puzzle
- This topic has 31 replies, 5 voices, and was last updated 10 hours, 52 minutes ago by
c4cc.
-
AuthorPosts
-
2025-07-14 at 3:48 pm #83035
c4cc
CustomerUnder console.log, tried to put window.PetraBasicMoveRange under the right side, under JSON3 and under windowprototype, still didn’t work.
Which part of the right side of console log did you put window.PetraBasicMoveRange?
Also tried to write it on the left side, still didn’t work when I went fullscreen
2025-07-14 at 4:27 pm #83039bigmike814
Customerthe part you type in. I see the PetraBasicMoveRange is set in your window as well as the PetraDashRange. You accessed the window and it gave you your window object.
Taking it one step further window.PetraBasicMoveRange should give you the value of your PetraBasicMoveRange key as its set as a key/value in the window object. It’s the same for calling functions or what not.
Thats why you can call functions using v3d.puzzles.procedures, type that in the console and you will see all the procedures you set in the app. thats your address to the object that your procedures are in, so if you put v3d.puzzles.procedures.myFunction (if you have it), it will run that function. Or if it’s an object you can reference or set it that way. Or if you set it = 12 then it should set it.
The window is the map of your app so you can access what you need.
2025-07-14 at 4:45 pm #83040c4cc
Customer2025-07-14 at 5:09 pm #83043c4cc
Customer2025-07-14 at 5:43 pm #83044bigmike814
CustomerOn the first response:
look up v3d.puzzles.procedures and it will give you a list of all the procedures. You can call one of them by typing v3d.puzzles.procedures.theNameOfTheProcedureYouWantToCall
you don’t want to try setting anything to the window with v3d.puzzles.procedures.window…
To set a window object/key you just set window.PetraBasicMove = 12 since you defined this to the window and use it in your procedure, you can set the move rate
window.PetraBasicMove = 12
and then call the function (procedure) that calls the movement.
v3d.puzzles.procedure.movePetra if your function is not setting the speed it uses then it will change the speed.
It’s really hard without seeing what exactly you are trying to accomplish, but just trying to help you understand the concepts.
You have to re-fire the procedure or it wont change.
here are some screenshots of a simple example to conceptualize it.
2025-07-14 at 5:46 pm #83049bigmike814
CustomerHere is another example on how to set the window key petraBasicSpeed value to 12 from the console and then you have two functions that you can call to set it to the defined amount.
Hope this helps
2025-07-14 at 6:24 pm #83052c4cc
Customer2025-07-14 at 6:43 pm #83055bigmike814
CustomerNo problem. Hopefully it makes sense, or at least you can get what you need to get accomplished.
2025-07-14 at 6:52 pm #83056c4cc
Customer2025-07-14 at 7:19 pm #83057bigmike814
Customerjust call the function when the fullscreen is active. or when it is active set the variable to the window and then call the function that changes the speed.
doing it in the console.log is just the easiest way to explain it and you can instantly see what your calling and if it works or not, but what you really want is to use those calls in the code so it can react.
I don’t see why you cant do all of this from the puzzle environment. but its good to get outside of it anyway, for extra learning and incase you need to add more functionality to anything.
I would say the best help you can get is trying chatGPT, if you haven’t yet. It’s not the best for v3d since its puzzles and not code, but if you need code help, it’s great.
2025-07-14 at 7:33 pm #83058c4cc
Customertried in visual studio code, in fullscreen function still no change. Any suggestions?
Wait, so you’re telling me that doing it in console log is not to trigger event, but to see if it works, as in no error?
2025-07-14 at 7:44 pm #83062c4cc
Customerdoing it in the console.log is just the easiest way to explain it and you can instantly see what your calling and if it works or not, but what you really want is to use those calls in the code so it can react.
I don’t see why you cant do all of this from the puzzle environment. but its good to get outside of it anyway, for extra learning and incase you need to add more functionality to anything.
I just think it’s better to put fullscreen button outside verge3d, like that of a youtube video’s. As you say, it’s definitely good to learn more coding for more versatility and flexibility to website or app.
-
This reply was modified 1 day, 18 hours ago by
c4cc.
2025-07-14 at 9:12 pm #83064bigmike814
CustomerYou can call any function in the console, so its easier to test that you’re calling it correctly that way rather than putting it in code.
So I should have explained this too, to call the function you have to put the () at the end. It looks like you are just referencing the key values for Petra —not actually calling them, so that wont work.
try this
let elem = document.getElementById(gamescreen);function fullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
window.PetraBasicSpeed = 0.007;
console.log(‘PetraBasicSpeed set (standard):’, window.PetraBasicSpeed);
} else if (elem.webkitRequestFullscreen) { // Safari
elem.webkitRequestFullscreen();
window.PetraBasicSpeed = 0.12;
console.log(‘PetraBasicSpeed set (webkit):’, window.PetraBasicSpeed);
} else if (elem.msRequestFullscreen) { // IE11
elem.msRequestFullscreen();
window.PetraBasicSpeed = 0.25;
console.log(‘PetraBasicSpeed set (ms):’, window.PetraBasicSpeed);
}
}
and then you have to recall the function that sets the speed. How are you setting the speed? Whats the function look like?-
This reply was modified 1 day, 17 hours ago by
bigmike814.
2025-07-15 at 3:07 am #83066c4cc
CustomerThanks again for all your patience and attempts to guide me. That said, I tried this and now I can’t even trigger fullscreen
-
This reply was modified 1 day, 10 hours ago by
c4cc.
2025-07-16 at 2:36 am #83126bigmike814
Customeryeah, my bad. I thought I changed it to double quotes.
Try it like this. The underline in the editor is because it was throwing syntax errors. It doesn’t like the single quote in this instance. These are ok –> ‘
but these —> ’
are not ok,believe it or not. It’s just a quirk you’ll run into eventually, especially if you have AI helping you. If you use the double quotes you wont have to worry.
let elem = document.getElementById(gamescreen);
function fullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
window.PetraBasicSpeed = 0.007;
console.log(“PetraBasicSpeed set (standard):”, window.PetraBasicSpeed);
} else if (elem.webkitRequestFullscreen) { // Safari
elem.webkitRequestFullscreen();
window.PetraBasicSpeed = 0.12;
console.log(“PetraBasicSpeed set (webkit):”, window.PetraBasicSpeed);
} else if (elem.msRequestFullscreen) { // IE11
elem.msRequestFullscreen();
window.PetraBasicSpeed = 0.25;
console.log(“PetraBasicSpeed set (ms):”, window.PetraBasicSpeed);
}
} -
This reply was modified 1 day, 18 hours ago by
-
AuthorPosts
- You must be logged in to reply to this topic.