8680's Lua Thread
Moderator: Forum Moderators
8680's Lua Thread
I made/am making tags to replace/improve various macros. So far I have three tags fully written and tested against the old macros:
I hope this isn't resented or against the rules.
{FOREACH} > [foreach]
{REPEAT} > [loop]
{PUT_TO_RECALL_LIST} > [put_to_recall_list]
-
- Posts: 462
- Joined: June 8th, 2006, 3:25 am
Re: 8680's Lua Thread
You might find the contents of the following thread interesting: http://forums.wesnoth.org/viewtopic.php?f=58&t=30983. I am especially curious if your foreach tag can handle the use-case I brought up in that thread, where the array itself (not just the individual elements) is being modified inside of the loop.
Re: 8680's Lua Thread
@Exasperation: I'll look into that. But I'm traveling currently, so it'll take me a while to fully write and test it. I'm thinking an alternate mode (mode="full") that would use while instead of for, and enable an [index] tag that could increment or decrement the index by a specified amount and jump to a specified index. I'd also add this to [loop], and I'll add a [break] tag (maybe with a filter) to both. Phew... this'll require rewriting handle_event_commands().
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: 8680's Lua Thread
Don't.8680 wrote:this'll require rewriting handle_event_commands().
If you want to have any chance to get the patches into core don't modify that function. You could start by the code I posted in that thread Exasperation linked to. I had stopped coding [foreach] due to the severe issues brought up by his post.
IMO it requires writing a lua iterator libary. Sad to say there doesn't seem to be an official one, and wesnoth needs one IMO. Basically the equivalent of what's apparently used in the current C++ array implementation (since such advanced array modifications do work).
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: 8680's Lua Thread
@Anonymissimus: Er, I meant copying it, not replacing it, though reading that it does sound like I meant replacing it. Is copying it allowed?
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: 8680's Lua Thread
In my code I had the call wml_actions[tag_name](cfg). Why don't you do that ?8680 wrote:@Anonymissimus: Er, I meant copying it, not replacing it, though reading that it does sound like I meant replacing it. Is copying it allowed?
Why would you need to copy it ? Redundant code is always bad.
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: 8680's Lua Thread
Can that handle [insert_tag]?Anonymissimus wrote:In my code I had the call wml_actions[tag_name](cfg). Why don't you do that?