Set variables problem

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
ShadowWalker
Posts: 10
Joined: July 18th, 2013, 12:15 pm

Set variables problem

Post by ShadowWalker »

I've written this code as part of an event:

Code: Select all

	  [set_variables]
        name=inspireloyalty
        mode=append
        [value]
          woundedunit=$unit.id
  	  attackingunit=$second_unit.id
  	  timeOfattack=$turn_number
        [/value]
    [/set_variables]
	  
	  {FOREACH inspireloyalty i}
	  
	  [message]
         speaker=narrator
         message= _ "$inspireloyalty[i].woundedunit $inspireloyalty[i].attackingunit $inspireloyalty[i].timeOfattack"
      [/message]

     {NEXT	i}
What I intend is to append my array with three new variables every time the event is called (and the show the whole array for debugging).
It in fact does, is append the array, but only with an additional set of the first entry. When I try to use mode insert, a new element is added, but all previously recorded entries are replaced with the new set of data.

Any idea how I can get the game to store an unique set of data each time the event is called?
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Set variables problem

Post by Ravana »

First thing i noticed here is that $inspireloyalty. should be $inspireloyalty[$i].
As such mistake might be only in that part while [set_variables] part is correct.
ShadowWalker
Posts: 10
Joined: July 18th, 2013, 12:15 pm

Re: Set variables problem

Post by ShadowWalker »

Thx, it was indeed my debugging code that was faulty not the part that actually does something.
Post Reply