How does one make a reduceable *object* which sticks ...

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.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: How does one make a reduceable *object* which sticks ...

Post by Sapient »

gladly, but first explain what you mean by "using ranges of commands"?

also, did you get it working as provided (without "ranges")?
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Actually, it should be obvious on how I tried to get it working without an array. It was one of my posts. Now what I mean is in Visual Basic 6 you actually don't need arrays because of

Code: Select all

Dim Praychance As Integer

*Put in code which selects a random number 1-20 for Praychance (it has been a while since I was in VB 6 or similar class)

Select Case Praychance

Case 1

*Do stuff

Case 2

*Do stuff
...

Case Else

End Select
It was along this line which I tried to work on, but I don't know if there IS a "Select Case" for WML.

Your array idea would probably logical do something like this in VB:

Code: Select all

Dim Prayarray(1 to 20) as Integer

*put in code which selects 1 of the numbers and makes it equal to 1 or true and take the rest and make them equal to 0

Select case Prayarray (I am not sure how to write it in VB)

Case 1

*Do stuff

Case 2

*Do other stuff
...
Case Else

End Select
The thing is I don't know really how to work with arrays except minimally and only in VB.

Could you explain how arrays work in WML or lead me to a *place* where it is *taught*?
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: How does one make a reduceable *object* which sticks ...

Post by Sapient »

In that case, the code I posted already does what you are asking.
Maybe you should read over it again a few more times and let me know if you have any more specific questions. Or just try using it and verify if it works as you intended.

Also, there is a sticky post at the top of this forum that deals specifically with using array variables in WML. There is also a [switch] statement that does something similar to what you are asking, if you prefer that method.

Check the WML Reference if you need more details about the switch statement.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Thank you, but it still does not work, probably because I am still not sure how to *activate* it. This is what I so far came up with...

Code: Select all

###Pray01###
[event]
	name=turn 1
	first_time_only=yes
	[set_menu_item]
# makes an option on the right click menu
		id=celpray01
		description="Pray"
		[show_if]
			[have_unit]
				side=$side_number
				x,y=$x1,$y1
				[filter]
					race="celestial"
				[/filter]
# only celestials now have this option
			[/have_unit]
		[/show_if]
		[command]
			[store_gold]
				side=$side_number
				variable=goldamount
			[/store_gold]
			[store_unit]
				[filter]
					x=$x1
					y=$y1
				[/filter]
				kill=yes
				mode=replace
				variable=worker
			[/store_unit]
			[if]
				[variable]
					name=worker.moves
					greater_than=0
				[/variable]
#accepts and apparently works to right here
				[then]
					[set_variables]
  						name=possible_commands
  						[possible_commands18]
							[gold]
								side=$side_number
								amount=1
							[/gold]
							[set_variable]
								name=worker.moves
								add=2
# added this to ensure visibility of effect if triggered, same thing for the rest of the named 
# possible_commands, not seemed to be triggered
							[/set_variable]
  						[/possible_commands18]
  						[possible_commands19]
							[set_variable]
								name=wood_$side_number
								add=1
							[/set_variable]
							[set_variable]
								name=worker.moves
								add=2
							[/set_variable]
  						[/possible_commands19]
  						[possible_commands15]	
							[set_variable]
								name=worker.hitpoints
								add=1
							[/set_variable]
							[set_variable]
								name=worker.moves
								add=2
							[/set_variable]
  						[/possible_commands15]
  						[possible_commands16]
							[set_variable]
								name=worker.experience
								add=1
							[/set_variable]
							[set_variable]
								name=worker.moves
								add=2
							[/set_variable]
  						[/possible_commands16]
  						[possible_commands17]
							[set_variable]
								name=worker.moves
								add=2
							[/set_variable]
  						[/possible_commands17]
					[/set_variables]
					{RANDOM 0..19}
					[insert_tag]
  						name=command
  						variable=possible_commands[$random]
					[/insert_tag]
# apparently ignores above, except where noted
					[unstore_unit]
						variable=worker
					[/unstore_unit]
				[/then]
				[else]
					[unstore_unit]
						variable=worker
					[/unstore_unit]
				[/else]
			[/if]
		[/command]
	[/set_menu_item]
[/event]
The thing is the wesnoth recognizes and doesn't attack it, but as of right now it seems to ignore what is supposed to do the random effect. Are you sure that what you gave me has a trigger attached? If so, then please correct me on how I apparently dodged it.

My bad, it is worse than I thought.

Code: Select all

			[have_unit]
				side=$side_number
				x,y=$x1,$y1
				[filter]
					race="celestial"
				[/filter]
			[/have_unit]
Does not seem to do anything, since everyone can use it ...

Also, I tried tampering with the original idea and got

Code: Select all

###Prayer02###
[event]
	name=turn 1
	first_time_only=yes
	[set_menu_item]
		id=pray01
		description="pray"
		[show_if]
			[have_unit]
				side=$side_number
				x,y=$x1,$y1
				[filter]
					race="celestial"
				[/filter]
			[/have_unit]
		[/show_if]
		[command]
			[store_gold]
				side=$side_number
				variable=goldamount
			[/store_gold]
			[store_unit]
				[filter]
					x=$x1
					y=$y1
				[/filter]
				kill=yes
				mode=replace
				variable=worker
			[/store_unit]
			[if]
				[variable]
					name=worker.moves
					greater_than=0
				[/variable]
				[then]
					[set_variable]
						name=worker.moves
						add=-1
					[/set_variable]
					[set_variable]
						name=praychance01
						rand=0..19
					[/set_variable]
					[if]
						[variable]
							name=praychance01
							is_equal_to=15
						[/variable]
						[then]
							[gold]
								side=$side_number
								amount=1
							[/gold]
							[unstore_unit]
								variable=worker
							[/unstore_unit]
						[/then]
# lands on 1 gold too often to be a coincidence as the first thing that popped up, implying 1st option is only option
						[else]
							[if]
								[variable]
									name=praychance01
									is_equal_to=16
								[/variable]
								[then]
									[set_variable]
										name=wood_$side_number
										add=1
									[/set_variable]
									[unstore_unit]
										variable=worker
									[/unstore_unit]
								[/then]
								[else]
									[if]
										[variable]
											name=praychance01
											is_equal_to=17
										[/variable]
										[then]
											[set_variable]
												name=worker.hitpoints
												add=1
											[/set_variable]
											[unstore_unit]
												variable=worker
											[/unstore_unit]
										[/then]
										[else]
											[if]
												[variable]
													name=praychance01
													is_equal_to=18
												[/variable]
												[then]
													[set_variable]
														name=worker.experience
														add=1
													[/set_variable]
													[unstore_unit]
														variable=worker
													[/unstore_unit]
												[/then]
												[else]
													[if]
															[variable]
																name=praychance01
																is_equal_to=19
															[/variable]
															[then]
																[set_variable]
																	name=worker.moves
																	add=2
																[/set_variable]
																[unstore_unit]
																	variable=worker
																[/unstore_unit]
															[/then]
															[else]
																[then]
																	[unstore_unit]
																		variable=worker
																	[/unstore_unit]
																[/then]
															[/else]
														[/if]
													[/else]
												[/if]
											[/else]
										[/if]
									[/else]
								[/if]
							[/else]
						[/if]
					[/then]
					[else]
						[unstore_unit]
							variable=worker
						[/unstore_unit]
					[/else]
				[/if]
			[/command]
	[/set_menu_item]
[/event]
Will someone help me make either of the prayers work?
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How does one make a reduceable *object* which sticks ...

Post by zookeeper »

Col Lightbeam wrote:

Code: Select all

					[insert_tag]
  						name=command
  						variable=possible_commands[$random]
					[/insert_tag]
# apparently ignores above, except where noted
Well, no possible_commands array is ever created, because your [set_variables] doesn't have a single [value] or [literal].
Col Lightbeam wrote:

Code: Select all

is_equal_to=
There ain't no such thing as is_equal_to=.
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Well then why don't you tell me how to fix it? What does one say instead of

Code: Select all

is_equal_to=
? Or how do I fix the other given how much information I have given you?
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: How does one make a reduceable *object* which sticks ...

Post by Max »

User avatar
Pentarctagon
Project Manager
Posts: 5732
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How does one make a reduceable *object* which sticks ...

Post by Pentarctagon »

pages also useful for finding stuff in general: the BuildingScenariosIndex and WMLReference.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply