We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How to reference a Verge 3d varible in a Javascript Code Puzzle

Home Forums General Questions How to reference a Verge 3d varible in a Javascript Code Puzzle

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #83035
    c4cc
    Customer

    Under 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

    • This reply was modified 1 day, 22 hours ago by c4cc.
    • This reply was modified 1 day, 22 hours ago by c4cc.
    • This reply was modified 1 day, 22 hours ago by c4cc.
    #83039
    bigmike814
    Customer

    the 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.

    #83040
    c4cc
    Customer

    I tried as below, but still no change? How would you input the code here? Sorry a complete example would be helpful

    • This reply was modified 1 day, 21 hours ago by c4cc.
    • This reply was modified 1 day, 21 hours ago by c4cc.
    #83043
    c4cc
    Customer

    Also, even though this code technically works, the PetraBasicMoveRange var in fullscreen still has the same speed as in small windows.

    #83044
    bigmike814
    Customer

    On 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.

    #83049
    bigmike814
    Customer

    Here 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

    #83052
    c4cc
    Customer

    Thanks for your answer

    • This reply was modified 1 day, 20 hours ago by c4cc.
    • This reply was modified 1 day, 20 hours ago by c4cc.
    #83055
    bigmike814
    Customer

    No problem. Hopefully it makes sense, or at least you can get what you need to get accomplished.

    #83056
    c4cc
    Customer

    I tried to do the first one, sadly no change in speed during fullscreen

    Do i go to console.log when the verge3d is in fullscreen to activate this:

    or just normal screen?

    #83057
    bigmike814
    Customer

    just 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.

    #83058
    c4cc
    Customer

    tried 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?

    • This reply was modified 1 day, 19 hours ago by c4cc.
    • This reply was modified 1 day, 19 hours ago by c4cc.
    • This reply was modified 1 day, 19 hours ago by c4cc.
    #83062
    c4cc
    Customer

    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 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.
    #83064
    bigmike814
    Customer

    You 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.
    #83066
    c4cc
    Customer

    Thanks again for all your patience and attempts to guide me. That said, I tried this and now I can’t even trigger fullscreen :cry:

    • This reply was modified 1 day, 10 hours ago by c4cc.
    #83126
    bigmike814
    Customer

    yeah, 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);
    }
    }

Viewing 15 posts - 16 through 30 (of 32 total)
  • You must be logged in to reply to this topic.