Conveniently creating location arrays

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
BajMic
Posts: 42
Joined: January 24th, 2023, 1:22 am

Conveniently creating location arrays

Post by BajMic »

Hello,

Is there a way to store location in such a way that I can loop through every hex?

My intention is to fill a space with random elements, without making a lengthy WML block.

This is more or less what I am trying to achieve:

Code: Select all

		[store_locations]
			name=orchard
            		x=22,23,24,25,21,22,23,24,26,25
            		y=28,29,29,30,29,29,30,30,30,31
		[/store_locations]

		[foreach]
			array=orchard
			[do]
				[set_variable]
					name=treesize
					rand=72,70,68,66,64,62
				[/set_variable]
				[item]
					x=$this.item.x
					y=$this.item.y
            				image=scenery/oak-leaning.png~SCALE($treesize,$treesize)
        			[/item]
			[/do]
		[/foreach]
Thank you.
BajMic
Posts: 42
Joined: January 24th, 2023, 1:22 am

Re: Conveniently creating location arrays

Post by BajMic »

Ok, solved. Thanks anyway.

Code: Select all

		[store_locations]
			variable=orchard
            		x=22,23,24,25,21,22,23,24
            		y=28,29,29,30,29,29,30,30
		[/store_locations]

		[foreach]
			array=orchard
			[do]
				[set_variable]
					name=treesize
					rand=72,70,68,66,64,62
				[/set_variable]
				[item]
					x,y=$this_item.x,$this_item.y
            				image=scenery/oak-leaning.png~SCALE($treesize,$treesize)
        			[/item]
			[/do]
		[/foreach]
Post Reply