Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

What does this error mean ?
Started by filippo66627 Jan 29 2020 09:41 AM

6 replies to this topic

Best Answer nick_sherman , 29 January 2020 - 10:10 AM

Well, firstly, did you mean tick or tick1 in your initial post? 

 

Secondly, it doesn't really 'work'. You're just avoiding a runtime error by doing nothing if it is nil. Sometimes that is ok if an object can indeed be nil in certain circumstances, but I suggest not in this case.

 

Track through everything that happens to 'tick' or 'tick1' or whatever it is, from the time it is created to the time you try to insert it. Check whether it's nil right after creation, which would suggest the image doesn't exist. 

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

Hi guys im getting this error when im switching a scene. I did check if it was sceneGroup.insert(object) as corona was suggesting but its actually sceneGroup:insert(object)

 

here is the line of code that gives me this error 

 

 sceneGroup:insert(tick1)

 

 

Attached Files



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,960 posts
  • Corona SDK

is tick1 nil?



[TOPIC: post.html]
#3

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

is tick1 nil?

no , 

local tick = widget.newButton
{
  top = 22.5,
  left = 142,
  width = 25,
  height = 25,
  defaultFile = ("Sfondi/icons/tick.png"),
  overFile = ("Sfondi/icons/tick.png"),
  onEvent = handleButtonEventTick 
 } 


[TOPIC: post.html]
#4

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,960 posts
  • Corona SDK

Well, that's lovely but doesn't mean it isn't nil, could you check?

 

EDIT: In fact, you're inserting tick1 but that object is called tick....but I'm guessing another typo...?

 

Put 'print(tick1)' before the insert line.

 

Although I seem to remember your console doesn't work? Is that still the case? If so you're basically trying to fly a plane blind.

 
if tick ~= nil then
  sceneGroup:insert(tick)
end
 

If the above code works, then tick is nil and you need to find out why.



[TOPIC: post.html]
#5

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

Well, that's lovely but doesn't mean it isn't nil, could you check?

 

In fact, you're inserting tick1 but that object is called tick....but I'm guessing another typo...?

 

Put 'print(tick1)' before the insert line.

 

Although I seem to remember your console doesn't work? Is that still the case? If so you're basically trying to fly a plane blind.

 
if tick ~= nil then
  sceneGroup:insert(tick)
end
 

If the above code works, then tick is nil and you need to find out why.

oh fairs, now it works. Why is it nil tho haha 



[TOPIC: post.html]
#6

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,960 posts
  • Corona SDK

  Best Answer

Well, firstly, did you mean tick or tick1 in your initial post? 

 

Secondly, it doesn't really 'work'. You're just avoiding a runtime error by doing nothing if it is nil. Sometimes that is ok if an object can indeed be nil in certain circumstances, but I suggest not in this case.

 

Track through everything that happens to 'tick' or 'tick1' or whatever it is, from the time it is created to the time you try to insert it. Check whether it's nil right after creation, which would suggest the image doesn't exist. 



[TOPIC: post.html]
#7

filippo66627

[GLOBAL: userInfoPane.html]
filippo66627
  • Enthusiast

  • 66 posts
  • Corona SDK

Well, firstly, did you mean tick or tick1 in your initial post? 

 

Secondly, it doesn't really 'work'. You're just avoiding a runtime error by doing nothing if it is nil. Sometimes that is ok if an object can indeed be nil in certain circumstances, but I suggest not in this case.

 

Track through everything that happens to 'tick' or 'tick1' or whatever it is, from the time it is created to the time you try to insert it. Check whether it's nil right after creation, which would suggest the image doesn't exist. 

okay got it, thank you as always 




[topic_controls]
[/topic_controls]