function update(self, dt) 3
for i, p in ipairs(pieces) do 4
local pos = go.get_position§
if pos.x <= -228 then 5
pos.x = 1368 + (pos.x + 228)
end
pos.x = pos.x - self.speed
go.set_position(pos, p) 6
end
end**
get an error in line 2
Description Resource Path Location Type
unexpected symbol near '1’
ground.script /Getting Started Tutorial/content/main line 2 Problem
You must remove the numbers at the end of the lines.
Try this:
local grounds = {"ground0", "ground1", "ground2", "ground3", "ground4", "ground5", "ground6"}
function init(self)
self.speed = 6
end
function update(self, dt)
for i, ground in ipairs(grounds) do
local pos = go.get_position(ground)
if pos.x <= -228 then
pos.x = 1368 + (pos.x + 228)
end
pos.x = pos.x - self.speed
go.set_position(pos, ground)
end
end
Thanks !
I ll get there in the end and learn lua but for the moment i want to get the hang of the editor first
I just copied the instruction in the tutorial which said to copy and paste it
BTW the tutorial needs to be corrected then as i see the 1 at the end of the line
this is the incriminating bit
Right-click the “main” folder in the Project Explorer and select New ▸ Script File. Name the new file "ground.script"
Double click the new file to bring up the Lua script editor.
Delete the default content of the file and copy the following Lua code into it, then save the file.
ground.script
local pieces = { “ground0”, “ground1”, “ground2”, “ground3”,
“ground4”, “ground5”, “ground6” } 1
maybe the numbers at the side of the lua script should be commented with // so they do not generate code errors
seems you need to remove all the 1 - 6 numbers
The numbers are there because they are annotations on the web page version of the source with text below explaining each part. When you copy and paste code that’s why they show up if there are any.
Might be too much time to do but if the codeblocks had line numbers to the left you could bold the line numbers you want to highlight and then talk about them below.
for a noob it s quite confusing , i d suggest either take them out or comment them ouit with // like in c#
i ve never done lua , and are a beginner in c# but i would have realized what was wrong with c#
alternatively the copy and paste bit in the instruction should be edited out or changed to warn of the numbers
thanks again to everybody !
i m sure i ll be back soon with more problems
In my opinion, I would rather just see a warning above the code block, that makes the reader pay attention to the annotation. The formatting of the numbers makes it reasonably obvious that they’re something special, and with an “Attention: Numbers formatet as … is related to the annotations below the code block”, there shouldn’t be any doubt left. Just by reading the code, line by line, one should notice the pattern.
As it stands now, one either catches the numbers and remove them, or get an error, forcing one to debug and by that increase one’s knowledge. And if people get stuck, we’re always here, ready to guide them as best we can.