Code Monkey home page Code Monkey logo

Comments (9)

rgrams avatar rgrams commented on July 18, 2024

Hmm, that's quite strange. Line 145 in camera.script is just this:

self.data.lpos = go.get_position()

What dependency link do you have in your game.project?
Did you modify any of the rendercam files at all?

from rendercam.

Learningtotry avatar Learningtotry commented on July 18, 2024

I did not modify anything until this error first appeared. Since it has appeared I have tried debugging with print statements such as print(go.get_position()), print(self.data.lpos) the second print statement actually caused an error once! I checked and that line you gave is the same in my code, unaltered.

from rendercam.

Learningtotry avatar Learningtotry commented on July 18, 2024

Does it somehow think that self.data is a vector instead of a container? That would explain why it says vmath.vector4 only has fields x, y, z, w. However, it outputs a table in hexadecimal when I put it in a print function. I have tried debugging with

function on_message(self, message_id, message, sender)
if message_id == hash("post-update") then
-- have to update pos after update or it jitters like crazy
print(self.data)
print(self.data.lpos)
print("my pos is ", go.get_position())
-- Update transform stuff
self.data.lpos = go.get_position()
But the go.get_position() statement is not printed

from rendercam.

rgrams avatar rgrams commented on July 18, 2024

Very very strange. I'm sorry you're having this problem, I've never heard of anything like this before. Is it possible for you to zip up your project and send it to me? Either attach it here, or send me a message with it on the forum?

Does it somehow think that self.data is a vector instead of a container?

Yes, that's what it sounds like. You should only get that error when trying to set a specific key on a vector4. Maybe it's getting overwritten somewhere by mistake...oh, but you already verified that it's a table, right? Hmm. This is the first error you get in the console, right? There aren't any others before?

from rendercam.

Learningtotry avatar Learningtotry commented on July 18, 2024

Zipped.zip
Here is the file I have tried to zip.

from rendercam.

Learningtotry avatar Learningtotry commented on July 18, 2024

While you're here, what do you think is the best way to learn a programming language?

from rendercam.

rgrams avatar rgrams commented on July 18, 2024

OK, thanks a lot for the project.
The first thing I tried was removing your player.script from the scene. That solved the problem, there were no errors after that.

The problem was in your init function, this line:

go = vmath.vector4(0, 0, 0, 0)

You're defining a global variable, 'go' as a vector4.
Defold uses 'go' as the namespace (or module name) for all the game object functions. Like go.get_position(), go.set_position(), etc. So when you set 'go' as a global variable, you overwrite all those functions! :D

You should be very careful about setting global variables. Always use local when you initialize a variable name (including your functions!).

from rendercam.

rgrams avatar rgrams commented on July 18, 2024

As for learning a programming language, hmm...haha, that's a big question.

First of all, most programming languages are mostly the same. They may each use slightly different symbols for things, but in general they are very similar. They all have variables, types, functions, "scope", etc. So it's really about learning "programming", not learning one language in particular.

Anyway, for learning I think it's best to alternate between very "boring" studying (reading books and following basic exercises), and more "fun" experimenting on your own.

  • Too much "boring" studying, and you will lose interest.
  • Too much "fun" experimenting and you will never learn anything properly.

For the "boring" part:
Defold's lua manual is a very good overview to start with: https://defold.com/manuals/lua/
After that, start going through Programming in Lua, chapter by chapter: http://www.lua.org/pil/contents.html (and type in and run all the code yourself.)

For the "fun" part:
Play around with Defold! Keep it small. Try lots of different little tiny things so you get experience. Don't just copy-paste one piece of code that works, or you won't learn anything. Try re-creating the Defold examples yourself: https://defold.com/examples/basics/simple_move/ Maybe try making a small program that could be useful in real life, like a calculator or alarm clock or something. Just for fun. Try to make as many different things as you can, not just one big "perfect dream game".

from rendercam.

Learningtotry avatar Learningtotry commented on July 18, 2024

When I first started programming, I just copied the code I saw. Since then I have stopped that. I have already started going through the Lua tutorial. I think one point which has helped me a lot so far is that I once read a book on programming logic and design. Thanks for the help!

from rendercam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.