# Accessing property from a spawned instance (SOLVED)

**URL:** <https://forum.defold.com/t/accessing-property-from-a-spawned-instance-solved/1437>\
**Category:** Questions\
**Created:** [April 3, 2016, 5:22pm UTC](https://forum.defold.com/t/accessing-property-from-a-spawned-instance-solved/1437 "2016-04-03T17:22:07Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kgoya](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/kgoya/32/776_2.png) [@kgoya](https://forum.defold.com/u/kgoya)\
**Post date:** [April 3, 2016, 5:41pm UTC](https://forum.defold.com/t/accessing-property-from-a-spawned-instance-solved/1437/5 "2016-04-03T17:41:17Z")

</div>

World.script

```
require("main.hex")
go.property("TILESIZE", 35)

function init(self)
    -- Add initialization code here
    -- Remove this function if not needed
    
    self.width = 30
    self.height = 15
    
    self.tiles = {}
    
    for q = 1, self.width do
    	self.tiles[q] = {}
    	for r = 1, self.height do
    		local h = Hex(q, r)
    		local pix = hexToPixel(h, go.get("#", "TILESIZE"))
    		local tile_pos = vmath.vector3(pix.x, pix.y, -q*.001-r*.001)
    		
    		--local newtile = collectionfactory.create("#tiles_factory", tile_pos, nil, {}, 1)
    		local newtile = factory.create("#tiles_factory1", tile_pos, nil, {}, 1)		    
    		self.tiles[q][r] = newtile
    		pprint(newtile)
    		pprint(msg.url(newtile))
    		pprint(go.get(msg.url(newtile), "tiletype")) 		
    	end
   	end
   	
   	print("World built")
end

```

tile.script (from tile.go, prototype of tiles factory)

```
go.property("tiletype", hash("grass"))
go.property("passable", true)

function init(self)
	    
	local rng = math.random()
	
	if rng > .7 then
		go.set("#", "tiletype", hash("water"))
	end
    
    if self.type == hash("water") then
    	msg.post("#sprite", "play_animation", {id = hash("tileWater_full")})
    	go.set("#", "passable", false)
    else
    	msg.post("#sprite", "play_animation", {id = hash("tileGrass_full")})
    end
    
end

```

---

_[View the full topic](https://forum.defold.com/t/accessing-property-from-a-spawned-instance-solved/1437)._
