{CLEAR_VARIABLE} and [clear_variable] work in one place but
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.
{CLEAR_VARIABLE} and [clear_variable] work in one place but
not in another place. I can't get why {CLEAR_VARIABLE} just REFUSES to clear the variable. Is there any other way I can delete a variable?
Here's where it works.
Here's where it doesn't work.
Use of {DEBUG_MSG} and :inspect confirm that I'm using all the right variable names, and everything but {CLEAR_VARIABLE} or [clear_variable] is working there.
Here's where it works.
Code: Select all
#define MW_CLEAR_SPELL SIDE NAME
{VARIABLE spell_cleared no}
{FOREACH {SIDE}|.spells.option i}
[if]
{MW_VARIABLE {SIDE}|.spells.option[$i].name equals {NAME}}
[then]
[if]
{MW_VARIABLE spell_cleared not_equals yes}
[then]
{CLEAR_VARIABLE {SIDE}|.spells.option[$i]}
{VARIABLE spell_cleared yes}
[/then]
[/if]
[/then]
[/if]
{NEXT i}
{CLEAR_VARIABLE spell_cleared}
#enddef
Code: Select all
#define MW_DESTROY_SPELL SIDE NAME
{VARIABLE spell_destroyed no}
{FOREACH {SIDE}|.discarded_spells.option z}
[if]
{MW_VARIABLE {SIDE}|.discarded_spells.option[$z].name equals {NAME}}
[then]
[if]
{MW_VARIABLE spell_destroyed not_equals yes}
[then]
{CLEAR_VARIABLE {SIDE}|.discarded_spells.option[$z]}
{VARIABLE spell_destroyed yes}
[/then]
[/if]
[/then]
[/if]
{NEXT z}
{CLEAR_VARIABLE spell_destroyed}
#enddef
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
So if the spell_destroyed variable is set to yes and you output the value of ${SIDE}|.discarded_spells.option[$z].name immediately before it is cleared and immediately after, it shows the exact same value?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
It might help if we knew what was the value of {SIDE} when this was called, and which clear_variable isn't working.
Another question: have you tried checking the error log? I would turn the engine log to the info level.
--log-info=engine
(or similar command)
since so much is handled in lua now it might be prudent to use this instead:
--log-info=engine,scripting/lua,wml
Another question: have you tried checking the error log? I would turn the engine log to the info level.
--log-info=engine
(or similar command)
since so much is handled in lua now it might be prudent to use this instead:
--log-info=engine,scripting/lua,wml
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
That is correct.Pentarctagon wrote:So if the spell_destroyed variable is set to yes and you output the value of ${SIDE}|.discarded_spells.option[$z].name immediately before it is cleared and immediately after, it shows the exact same value?
{SIDE} = $side_number, the second code isn't working.Sapient wrote:It might help if we knew what was the value of {SIDE} when this was called, and which clear_variable isn't working.
Another question: have you tried checking the error log? I would turn the engine log to the info level.
--log-info=engine
(or similar command)
since so much is handled in lua now it might be prudent to use this instead:
--log-info=engine,scripting/lua,wml
Not sure how to do that.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
Did you check what exactly you were clearing?
Code: Select all
{VARIABLE aux {SIDE}|.discarded_spells.option[$z]}
[inspect]
name=$aux
[/inspect]
{CLEAR_VARIABLE $aux}
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
Make a link to wesnoth.exe with execution directory the wesnoth.exe's dir and command "C:\path\to\wesnoth.exe -log-debug=engine"A Guy wrote:Another question: have you tried checking the error log? I would turn the engine log to the info level.
--log-info=engine
(or similar command)
since so much is handled in lua now it might be prudent to use this instead:
--log-info=engine,scripting/lua,wml
Not sure how to do that.
There are hardly any corresponding log message calls in the lua or the lua-related C++ code, so passing scripting/lua generally is only helpful if one puts such a message there oneself.
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
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
It might help to know which CLEAR_VARIABLE in the second code block isn't working (clearing a discarded spell or clearing spell_destroyed).A Guy wrote:{SIDE} = $side_number, the second code isn't working.Sapient wrote:It might help if we knew what was the value of {SIDE} when this was called, and which clear_variable isn't working.
In any event, it works for me. I put the following (basically your two macros with feedback [message]s added, a definition for MW_VARIABLE, plus an event) into a test scenario:
CLEAR_VARIABLE test
Code: Select all
Pre-clear spell (1): kill
Post-clear spell (1):
Pre-clear discarded spell (0): test
Post-clear discarded spell (0): kill
Re: {CLEAR_VARIABLE} and [clear_variable] work in one place
Okay, I fixed the problem by changing the place the spell-destroying macro was called. So it wasn't the code, it was its location. Thanks guys.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.