LZulb
May 1, 2023, 8:12pm
1
Question: When logging, I don’t get any coords. How would I go about fixing this?
Repl link
<script type="text/javascript" src="glwindow.js"></script>
<script type="text/javascript">
let cvs = document.querySelector("#viewport-canvas");
let glwindow = new GLWindow(cvs);
cvs.addEventListener('mousemove', function (e) {
pos = glwindow.click({
x: e.clientX,
y: e.clientY
});
console.log(pos)
document.getElementById("x-value").textContent = pos.x;
document.getElementById("y-value").textContent = pos.y;
});
</script>
above this file, you can use ctrl + f and type in click
inside glwindow.js to find the function that should be returning coordinates.
Sorry for making this the 3rd question about this project.
1 Like
The repl is private, idk if that’s how you wanted it to be.
Now knowing what glwindow.js looks like, I can’t help you any further
LZulb
May 1, 2023, 8:37pm
3
Did the link not work?
I saw someone join it…
I just made the entire thing public.
LZulb:
x: e.clientX,
e
is not defined, as the Console (Ctrl ↑ J ) would complain.
1 Like
LZulb
May 1, 2023, 9:02pm
5
event
is supposed to be e
. Even so, it still doesn’t work.
Cannot read properties of undefined (reading 'x')
The link now works but points at a Go repl with what seems to be a hello world program.
Considering the error message, it might be possible that glwindow.click doesn’t return anything.
Perhaps consider changing this
document.getElementById("x-value").textContent = pos.x;
document.getElementById("y-value").textContent = pos.y;
into this
document.getElementById("x-value").textContent = e.clientX;
document.getElementById("y-value").textContent = e.clientY;
(re-use the variable e
’s attributes)
LZulb
May 1, 2023, 9:08pm
7
~/NewTest/place/web/root/desktop.html
And also,
I’m sorry, what does this mean?
As for the undefined-s, you will still log undefined
because, as said before, it seems like glwindow.click
is not returning anything (hence pos
will be given a value of undefined
).
What should glwindow.click
return? Can I have a look at the code?
LZulb
May 1, 2023, 9:16pm
9
That’s how you locate what I’m referring to.
Go inside the folder place → Folder web → folder root → file desktop.html
Click isn’t returning anything and that’s the problem.
1 Like
I think I found the problem. Line 168 in glwindow.js
, you are returning nothing if a certain condition is met.
Where is that math coming from? Double check it
Also sorry for being rude before, I didn’t properly understand
LZulb
May 1, 2023, 10:29pm
11
I’m going to do what is called “a pro gamer move” and quit working on coordinates. I can’t get it to work inside that environment, but can inside previous environments.
1 Like
system
Closed
May 8, 2023, 10:29pm
12
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.