Set variables problem
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.
-
- Posts: 10
- Joined: July 18th, 2013, 12:15 pm
Set variables problem
I've written this code as part of an event:
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?
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}
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?
Re: Set variables problem
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.
As such mistake might be only in that part while [set_variables] part is correct.
-
- Posts: 10
- Joined: July 18th, 2013, 12:15 pm
Re: Set variables problem
Thx, it was indeed my debugging code that was faulty not the part that actually does something.