attempt to index global 'self' (a nil value) line 62

-- requires local physics = require "physics" physics.start(); --Variables local background = display.newImage("bg.png"); local city1 = display.newImage("city1.png"); city1:setReferencePoint(display.BottomLeftReferencePoint); city1.x = 0 city1.y = 320 city1.speed = 1 -- local city2 = display.newImage("city1.png"); city2:setReferencePoint(display.BottomLeftReferencePoint); city2.x = 480 city2.y = 320 city2.speed = 1 local city3 = display.newImage("city2.png"); city3:setReferencePoint(display.BottomLeftReferencePoint); city3.x = 0 city3.y = 320 city3.speed = 2 local city4 = display.newImage("city2.png"); city4:setReferencePoint(display.BottomLeftReferencePoint); city4.x = 480 city4.y = 320 city4.speed = 2 function scrollCity(self,event) if self.x \< -477 then self.x = 480 else self.x = self.x - self.speed end end city1.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city1); city2.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city2); city3.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city3); city4.enterFrame = scrollCity Runtime:addEventListener("enterFrame", city4); -- jet local jet = display.newImage("redjet.png"); jet.x = 100 jet.y = 100 physics.addBody(jet, "dynamic", {density=.1, bounce=0.1, friction=.2, raduis=12}); function activateJets(slef,event) self:applyForce(0, -1.5, self.x, self.y) end function touchScreen(event) print("touch"); if event.phase == "began" then jet.enterFrame = activateJets Runtime:addEventListener("enterFrame", jet); print("began") end if event.phase == "ended" then print ("began") end end Runtime:addEventListener("touch", touchScreen);

sorry new to coding 

you spelled “self” wrong on line 61.

wow, lol. thanks

you spelled “self” wrong on line 61.

wow, lol. thanks

I have the same code…and i am getting the following error.

 "Attempt to index global ‘RunTime’ (a nil value).

stack traceback:

    c:?

     …main.lua:87: in main chunk

Do you want to relaunch your project?

If i click on yes - then the error persists…

if in the code i comment out the last line…it works fine…but not the “touch” functionality, which is

introduced in the code??

Please let me know.

PS: Screenshot attached.

Thanks.
Ram.S
 

@ramkis2002:   It should be ‘Runtime’ , in stead of ‘RunTime’  the capitalization is important. :slight_smile:

Thanks a bunch. I had it copied from the top and did not even change it.

Anyway it worked fine now…woo.

I have the same code…and i am getting the following error.

 "Attempt to index global ‘RunTime’ (a nil value).

stack traceback:

    c:?

     …main.lua:87: in main chunk

Do you want to relaunch your project?

If i click on yes - then the error persists…

if in the code i comment out the last line…it works fine…but not the “touch” functionality, which is

introduced in the code??

Please let me know.

PS: Screenshot attached.

Thanks.
Ram.S
 

@ramkis2002:   It should be ‘Runtime’ , in stead of ‘RunTime’  the capitalization is important. :slight_smile:

Thanks a bunch. I had it copied from the top and did not even change it.

Anyway it worked fine now…woo.