why give this error

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

why give this error

Post by davoodice2 »

Code: Select all

function BLABLA:OnMouseDown(moho, mouseEvent)
	local layersCount = 0
	repeat
		local layer1 = moho.document:LayerByAbsoluteID(layersCount)
		if layer1 then
			layersCount = layersCount + 1
			print( layer1:Parent():Name() )	
		end
	until not layer1
	...
line 256 attemt to tindex a nil value :| :? :? :( :(
parent is nil :roll:
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: why give this error

Post by synthsin75 »

Since you're looping through every layer in the document, top level layers do not have parents.
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: why give this error

Post by davoodice2 »

synthsin75 wrote: Mon Nov 22, 2021 7:32 pm Since you're looping through every layer in the document, top level layers do not have parents.
thanks
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
Post Reply