how can i send a List to another file?

Monkey Forums/Monkey Beginners/how can i send a List to another file?

yiotoo(Posted 2014) [#1]
How can I send a List to another Method write in other file?
I am trying in this exemple send the List blocks but get the error:
"Method 'qwer' cannot be accessed from here.



in the file teste1.monkey there is the code:

----------------------------------------------------------------------------------------------------------------------------
Import teste1ex
Import mojo

Class MyGame Extends App

'Global blocks:List<Block> = New List<Block>()
Field blocks:List<Block> = New List<Block>()
Method OnCreate()



SetUpdateRate(60)
GenerateFloor.qwer(blocks)
End

Method OnUpdate()


End

Method OnRender()
Cls(123,123,255)
End
End

Function Main()
New MyGame()
End
----------------------------------------------------------------------------------------------------------------------------

and the file teste1ex there is the code:

----------------------------------------------------------------------------------------------------------------------------


Class GenerateFloor

Method qwer(blocks:List<Block>)

For Local x:= 0 Until 5
blocks.AddLast(New Block(x))
End
End
End


Class Block
Field position:Int

Method New(x:Float)
position = x
End

End
----------------------------------------------------------------------------------------------------------------------------


Danilo(Posted 2014) [#2]
To write
GenerateFloor.qwer(blocks)
directly, change this Method to a Function.


With Method, you first need to create an instance of the GenerateFloor class:
Local gf:GenerateFloor = New GenerateFloor
gf.qwer(blocks)



yiotoo(Posted 2014) [#3]
it worked! ty!!!