So basically, since I am really not into lua at all, I firstly tried to just play around with the drone, and I wanted to write a program sooner or later, to harvest things. I tried to figure out how getPosition() works and what it actually returns when I tried to setup a variable with that method, it always threw "string expected, got table". Tried like position = {component.navigation.getPosition()}. <- That somehow had to do with something else, I don't know what exactly.
So I tried to get "getPosition()" to work, for to use it to craft some primitive if/else based actions.
What I tried lately was:
local drone = component.proxy(component.list('drone')())local position = component.navigation.getPosition()-- since I have the navigation upgrade on my droneif position ~=nilthen
drone.setStatusText("NotNil")-- since I couldn't get a value like setStatusText(position) to work, it expects stringendwhiletruedo
drone.move(0,0,0)-- to keep the drone runningend-- throws error oc:bios:2: attempt to index field 'navigation' (a nil value)
Also I couldn't get " x = require("X")" to work at all (I also don't know what I actually require when I say "x = require("component")" or "x= require("event") components? librarys? Can I get a list of these librarys that exist?)
The require attempts threw "attempt to call global 'require' (a nil value)". Things like "table.toString(tableName)" didn't work for me too. Guess toString is just not included maybe.
I am really not much into scripting yet, not to mention lua. The only thing I ever learned quite a bit was javascript es5 and a bit React.js with es6.
Quite frustrating for me to not even get a simple variable that calls a method of some component working in lua lmao.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hi,
I hope this is the right place to post this.
So basically, since I am really not into lua at all, I firstly tried to just play around with the drone, and I wanted to write a program sooner or later, to harvest things.
I tried to figure out how getPosition() works and what it actually returns when I tried to setup a variable with that method, it always threw "string expected, got table". Tried like position = {component.navigation.getPosition()}.<- That somehow had to do with something else, I don't know what exactly.So I tried to get "getPosition()" to work, for to use it to craft some primitive if/else based actions.
What I tried lately was:
Also I couldn't get " x = require("X")" to work at all (I also don't know what I actually require when I say "x = require("component")" or "x= require("event") components? librarys? Can I get a list of these librarys that exist?)
The require attempts threw "attempt to call global 'require' (a nil value)". Things like "table.toString(tableName)" didn't work for me too. Guess toString is just not included maybe.
I am really not much into scripting yet, not to mention lua. The only thing I ever learned quite a bit was javascript es5 and a bit React.js with es6.
Quite frustrating for me to not even get a simple variable that calls a method of some component working in lua lmao.
Thanks in advance for any help!
Link to post
Share on other sites