Unit side error
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: 1114
- Joined: December 9th, 2005, 2:38 am
Unit side error
So, I have an ability which summons a unit--but for some reason, the unit is always on side 1, instead of being on the side of the user of the ability. This code was written for 1.5, and had the problem then, too, but now it also throws up a Lua error saying that get_side has received a string where it expects a number.
Here's the ability:
Anyone know what's going on here? I have a feeling that it's something stupidly simple, but I haven't done anything with WML in so long that I can't for the life of my figure it out.
Thanks!
Here's the ability:
Code: Select all
#define SUMMON ABILITY UNIT GOLD ID
[set_menu_item]
id={ID}
description=_"Summon Elemental-{GOLD}g"
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
ability={ABILITY}
[not]
[filter_wml]
[status]
summoned_this_turn=yes
[/status]
[/filter_wml]
[/not]
[/have_unit]
[/show_if]
[command]
[store_unit]
[filter]
x=$x1
y=$y1
[/filter]
variable=unit
[/store_unit]
[store_side]
side=$side_number
variable=summoner
[/store_side]
[if]
[variable]
name=summoner.gold
greater_than_equal_to={GOLD}
[/variable]
[then]
[gold]
side=summoner
amount=-{GOLD}
[/gold]
{VARIABLE unit.status.summoned_this_turn yes}
{VARIABLE unit.moves 0}
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[unit]
side=summoner
type={UNIT}
generate_name=no
random_traits=no
x=$x1
y=$y1
moves=0
[/unit]
[/then]
[else]
[message]
speaker=unit
message=_"Not enough gold."
[/message]
[/else]
[/if]
[/command]
[/set_menu_item]
#enddef
Thanks!
Re: Unit side error
Code: Select all
[gold]
side=summoner
amount=-{GOLD}
[/gold]
-
- Posts: 1114
- Joined: December 9th, 2005, 2:38 am
Re: Unit side error
Thanks for the fast reply!
So, store side isn't working like I think it is? How do I call the side number after I store it?
So, store side isn't working like I think it is? How do I call the side number after I store it?
Re: Unit side error
side=$side_number
side=$summoner.side
side=$unit.side
All of those contain the number of the current side. You're already doing it right in your [store_side].
side=$summoner.side
side=$unit.side
All of those contain the number of the current side. You're already doing it right in your [store_side].
-
- Posts: 1114
- Joined: December 9th, 2005, 2:38 am
Re: Unit side error
Thanks, zookeeper; that's gotten rid of the Lua error.
Now, though, it thinks that the user never has enough gold--I stuck in a DEBUG_MSG just to check, and $summoner.gold is the right variable, but for some reason it's always registering as being less than GOLD. I tried switching them around, but the same thing happens, so I think it must be a problem somewhere else? Has [if] tag syntax changed since 1.5?
Thanks!
Now, though, it thinks that the user never has enough gold--I stuck in a DEBUG_MSG just to check, and $summoner.gold is the right variable, but for some reason it's always registering as being less than GOLD. I tried switching them around, but the same thing happens, so I think it must be a problem somewhere else? Has [if] tag syntax changed since 1.5?
Thanks!
Re: Unit side error
No, but my first guess would be that you changed name=summoner.gold to name=$summoner.gold or something, which would make the check fail because there's no variable named "34" or "22" or however much gold the side happens to have.Skizzaltix wrote:Now, though, it thinks that the user never has enough gold--I stuck in a DEBUG_MSG just to check, and $summoner.gold is the right variable, but for some reason it's always registering as being less than GOLD. I tried switching them around, but the same thing happens, so I think it must be a problem somewhere else? Has [if] tag syntax changed since 1.5?
- Enchanteur
- Posts: 72
- Joined: September 28th, 2009, 11:05 am
Re: Unit side error
I discovered than DEBUG_MSG can bug a function if it's not done correctly.
{DEBUG_MSG "myvalue: $value|"}
sometime i forget to write the " | " that close variable.
{DEBUG_MSG "myvalue: $value|"}
sometime i forget to write the " | " that close variable.
French Player. For now, I'm working on creation of abilitys and units with WML. My goal is to make an enhanced version of Elves, playable with standard campains. HERE : http://forums.wesnoth.org/viewtopic.php ... 58&start=0
-
- Posts: 1114
- Joined: December 9th, 2005, 2:38 am
Re: Unit side error
...that fixed it, zookeeper. Thanks! I guess I need to get used to a variable's name and a variable's value being two different things
For some reason, it generates a Lua error if I use $summoner.side anywhere, but it works just fine with $unit.side, so it's not a big deal in this case.
For some reason, it generates a Lua error if I use $summoner.side anywhere, but it works just fine with $unit.side, so it's not a big deal in this case.
Re: Unit side error
Looks like [store_side] doesn't store a .side key after all, so that'd explain it.Skizzaltix wrote:...that fixed it, zookeeper. Thanks! I guess I need to get used to a variable's name and a variable's value being two different things
For some reason, it generates a Lua error if I use $summoner.side anywhere, but it works just fine with $unit.side, so it's not a big deal in this case.
-
- Posts: 1114
- Joined: December 9th, 2005, 2:38 am
Re: Unit side error
Ah. I see. Does it store a .team value? I'm having another error with a different ability that would make sense if it didn't...
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Unit side error
wiki wrote:[store_side]
Stores information about a certain side in a variable. The variable will contain the member variables 'name', 'team_name', 'gold' and 'income', 'fog', 'shroud', 'hidden', 'user_team_name', 'colour', 'controller', 'village_gold' and 'recruit'.
* side: the side whose information should be stored
* variable: the name of the variable to store the information in
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign