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 12 posts - 16 through 27 (of 27 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 4 hours, 46 minutes ago by c4cc.
    • This reply was modified 4 hours, 44 minutes ago by c4cc.
    • This reply was modified 4 hours, 20 minutes 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 3 hours, 46 minutes ago by c4cc.
    • This reply was modified 3 hours, 44 minutes 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 2 hours, 11 minutes ago by c4cc.
    • This reply was modified 2 hours, 2 minutes 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 hour, 2 minutes ago by c4cc.
    • This reply was modified 56 minutes ago by c4cc.
    • This reply was modified 55 minutes 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 51 minutes ago by c4cc.
Viewing 12 posts - 16 through 27 (of 27 total)
  • You must be logged in to reply to this topic.