Sudipta's WML questions
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.
Re: Sudipta's WML questions
try this thenSudipta wrote: ↑June 15th, 2018, 12:14 pm Uhh, i used the commands u provided but both of them set turn number or turn limit number to 1 regardless of what value i put in it.
for example i useturn [8]
in debug mode but it sets turn number to 1. usingturn_limit [50]
sets turn limit to 1.
@enclave thanks for the alternate method but i find ravana's lua suggestions simpler. I'm just starting out so set_menu_item stuff goes over my head for now
:lua wesnoth.fire("modify_turns", { add=5 })
Re: Sudipta's WML questions
You can call every actionwml tag from lua with wesnoth.wml_actions.tag_name{key=value,key2=value2}. But using Lua to call WML to do something that Lua can do directly is not really useful.
Re: Sudipta's WML questions
You mean that instead of
:lua wesnoth.fire("modify_turns", { add=5 })
Sudipta could just write this:
:lua wesnoth.wml_actions.modify_turns { add=5 }
and it would be massively shorter and more simple?
I will actually try to compare performance of these 2 methods with 5k cycle just for curiosity.
Ps. i only offered to try this method since there seems to be a problem with proper lua method for Sudipta..
- Sudipta
- Posts: 217
- Joined: June 10th, 2015, 6:37 pm
- Location: Meditating under a waterfall, Heartfangs, Wesnoth
Re: Sudipta's WML questions
Both Ravana's and enclave's code works. I'm not gonna argue theory since it's results i care about
It is the mark of an educated mind to be able to entertain a thought without accepting it.
Playing Wesnoth since 2010, still there is so much left to play
Playing Wesnoth since 2010, still there is so much left to play
Re: Sudipta's WML questions
Do you mean the example above is working fine now, or did you have to modify it somehow?Sudipta wrote: ↑June 15th, 2018, 5:25 pm Uhh, i used the commands u provided but both of them set turn number or turn limit number to 1 regardless of what value i put in it.
for example i useturn [8]
in debug mode but it sets turn number to 1. usingturn_limit [50]
sets turn limit to 1.
Both Ravana's and enclave's code works. I'm not gonna argue theory since it's results i care about
- Sudipta
- Posts: 217
- Joined: June 10th, 2015, 6:37 pm
- Location: Meditating under a waterfall, Heartfangs, Wesnoth
Re: Sudipta's WML questions
Okay, let me break it down and dissolve whatever confusion there is.
The two lua commands Ravana posted first worked perfectly for me and got the job done. Then Shiki gave me a link of the CommandsWiki(thanks for that) and at first those debug commands didn't work because i included the [ ]. It was later pointed out to me where i was making a mistake and now that works perfectly too. Then enclave posted Lua+WML commands and those work too. So now i know 3 fundamentally different ways of changing turns and turn_limits
Now i'm a believer of the KISS principle, so i prefer using the shortest debug commands, but its good to know the alternate techniques. Hopefully that clears it up.
The two lua commands Ravana posted first worked perfectly for me and got the job done. Then Shiki gave me a link of the CommandsWiki(thanks for that) and at first those debug commands didn't work because i included the [ ]. It was later pointed out to me where i was making a mistake and now that works perfectly too. Then enclave posted Lua+WML commands and those work too. So now i know 3 fundamentally different ways of changing turns and turn_limits
Now i'm a believer of the KISS principle, so i prefer using the shortest debug commands, but its good to know the alternate techniques. Hopefully that clears it up.
It is the mark of an educated mind to be able to entertain a thought without accepting it.
Playing Wesnoth since 2010, still there is so much left to play
Playing Wesnoth since 2010, still there is so much left to play
- Sudipta
- Posts: 217
- Joined: June 10th, 2015, 6:37 pm
- Location: Meditating under a waterfall, Heartfangs, Wesnoth
Re: Sudipta's WML questions
I need help... again
I'm trying to use a Thunder macro to damage all units of the players side, but it doesn't work properly. Short version- the player fights a powerful elf lord, and when you reduce the Lord's hp to 0, he uses a powerful magic to almost kill all the player's units. It triggers in a last breath event. the code of the Thunder macro is
Basically it leaves all units alive with 1 hp left. But when i run it, i get some lua error messages, and then the scenario ends triggering the victory event. In the previous coding style, i used a modify unit tag to set all unit HP to 1 and that worked. But since harm_unit's looks a lot cooler i wanna use this instead.
i think the error is in the amount attribute. Please advise.
I'm trying to use a Thunder macro to damage all units of the players side, but it doesn't work properly. Short version- the player fights a powerful elf lord, and when you reduce the Lord's hp to 0, he uses a powerful magic to almost kill all the player's units. It triggers in a last breath event. the code of the Thunder macro is
Code: Select all
{THUNDER (
[harm_unit]
[filter]
side=1
[/filter]
amount="($this_unit.hitpoints - 1)"
kill=no
[/harm_unit]
)}
i think the error is in the amount attribute. Please advise.
It is the mark of an educated mind to be able to entertain a thought without accepting it.
Playing Wesnoth since 2010, still there is so much left to play
Playing Wesnoth since 2010, still there is so much left to play
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Sudipta's WML questions
Should be
"$($this_unit.hitpoints - 1)"
.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
- Sudipta
- Posts: 217
- Joined: June 10th, 2015, 6:37 pm
- Location: Meditating under a waterfall, Heartfangs, Wesnoth
Re: Sudipta's WML questions
Silly mistake. Thanks for pointing it out.
Another thing. How do i stop a unit from dying after its last breath event is triggered? In the above example, after the magic sequence the Elf Lord dies but he shouldn't. I tried using modify unit and and changing the HP but that doesn't prevent his death. I could use a
store_unit
tag and kill
attribute but i wonder if there's a more elegant solution ?It is the mark of an educated mind to be able to entertain a thought without accepting it.
Playing Wesnoth since 2010, still there is so much left to play
Playing Wesnoth since 2010, still there is so much left to play
Re: Sudipta's WML questions
store_unit
with kill
, then unstore_unit
is the most elegant way.