Request for a New Sticky Topic and a few other questions

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
Relic
Posts: 10
Joined: November 6th, 2007, 1:39 am

Request for a New Sticky Topic and a few other questions

Post by Relic »

How about a new sticky topic, for working wml code? Or one for stable and one for dev. The lack of example uses for every tag in the documentation, could be offset by people being able to see others working code. I know you can look into other campaigns, but having a one stop place for a large amount of code examples would probably help a lot of people out. Maybe a wiki page would be better, not sure.

Also, I am trying to figure out how to put monster names into an array. I want to be able to use them to call a monster placement macro so do they need to be with the ()'s or could I put the variable in ()'s when I call it. Basically, how do I successfully make an array that I can use to place a Vampire Bat and a Walking Corpse since there is a space in between the names.

I built some code that lays monsters randomly, but want it much more efficient since it is a huge amount of repetitive wml.
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Post by Mist »

Doing

Code: Select all

{VARIABLE <my_variable>.length <my_desired_length>}
gives you an empty array <my_variable> with <my_desired_length> elements. You can set, shirnk or enlarge any array in this way at any place in any event. Just remember that you can't assign values in following way

Code: Select all

<my_variable>[<any_number>]=<some_value>
each array member needs an container to hold the value like this

Code: Select all

<my_variable>[<any_number>].<some_container>=<some_value>
And about that sticky request :
It's not a good idea, it's hard to properly present the code on the forums and hard to properly search trough a thread content. The wiki is much better place for this.
Somewhere, between the sacred silence and sleep.
Disorder.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

Mist wrote:Doing

Code: Select all

{VARIABLE <my_variable>.length <my_desired_length>}
gives you an empty array <my_variable> with <my_desired_length> elements. You can set, shirnk or enlarge any array in this way at any place in any event.
This information is incorrect.
The other information was correct.

array.length should be considered a read-only value. changing it has no effect. array size is increased as it is needed.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Post Reply