tekelili advanced 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.
- artisticdude
- Moderator Emeritus
- Posts: 2424
- Joined: December 15th, 2009, 12:37 pm
- Location: Somewhere in the middle of everything
Re: tekelili WML noob questions
Adding to that, they are specifically ordered by id numerically, then alphabetically. So, for example, if you want a menu item with theSlowThinker wrote:items within the menu are ordered by id=
id=inventory
to be above the menu item with id=help
, you could change the id's to id=1inventory
and id=2help
. That will ensure that the game always places the inventory command above the help command. And of course, you don't even necessarily need to have the command's id match its right-click menu description, though I still recommend you try and keep them synchronized as closely as possible to avoid any unnecessary confusion. "I'm never wrong. One time I thought I was wrong, but I was mistaken."
Re: tekelili WML noob questions
How divide a variable and get a foating point result?
To be more precise, my current problem is this: I want divide a variable and round result to up integer if decimal part > 0.5 or round to low integer if decimal part <= 0.5
To be more precise, my current problem is this: I want divide a variable and round result to up integer if decimal part > 0.5 or round to low integer if decimal part <= 0.5
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
1.8: I'd try making the engine guess that you want floats; e.g don't use
[set_variable]divide=2
use
[set_variable]divide=2.0
In 1.9 you probably don't have that problem at all and I would personally use lua for it. Or formula language. Probably. Unless the whole thing I calculate there is simple enough.
[set_variable]divide=2
use
[set_variable]divide=2.0
In 1.9 you probably don't have that problem at all and I would personally use lua for it. Or formula language. Probably. Unless the whole thing I calculate there is simple enough.
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: tekelili WML noob questions
It is neccessary clear variables in a multiplayer scenario of just 1 map?
Until now, I have tried be clean while coding and clear all variables in the very moment they are not longer needed. But am working in a scenario that calls lot of subrutines that are iterated over long arrays, and I am interested in reduce as many steps as possible to improve speed. As I have no idea if dont clean variables will affact user once he ends scenario, hence my question.
Until now, I have tried be clean while coding and clear all variables in the very moment they are not longer needed. But am working in a scenario that calls lot of subrutines that are iterated over long arrays, and I am interested in reduce as many steps as possible to improve speed. As I have no idea if dont clean variables will affact user once he ends scenario, hence my question.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
WML interpretation is very slow, so that it does not matter much how performance-efficient wml code is. What causes lag is "wml bloat", the quantity of the whole wml of a scenario getting written to disk in autosaves, usually caused by overusage of macros to insert code into each other instead of custom events or lua. Personally I've noticed that complex SLFs can slow down at times (because the engine's SLF implementation isn't very efficient).tekelili wrote:It is neccessary clear variables in a multiplayer scenario of just 1 map?
Until now, I have tried be clean while coding and clear all variables in the very moment they are not longer needed. But am working in a scenario that calls lot of subrutines that are iterated over long arrays, and I am interested in reduce as many steps as possible to improve speed. As I have no idea if dont clean variables will affact user once he ends scenario, hence my question.
As for variables in a single scenario, in case they are scalar ones there's no need to care I think. Other than readability of the :inspect dialog. Of course since variables can contain arbitrarily complex wml they can also be subject of the above.
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
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: tekelili WML noob questions
I have a question that is slightly related to the wml bloat: if the addon contains its base WML code and contains many scenarios, the base WML is repeated in each scenario, and so the WML code becomes very bloated. I suppose I can avoid this if I put all the base WML code (i.e. the code that is common for all scenarios) into an era? Am I right? (I guess that measure won't decrease the size of saves thought)Anonymissimus wrote:What causes lag is "wml bloat", the quantity of the whole wml of a scenario getting written to disk in autosaves, usually caused by overusage of macros to insert code into each other instead of custom events or lua.
But now what to do if I need to use another external era(s) with my add-on? Can I include the file with the external_era into the code of my_addon_era?
What is SLF?Anonymissimus wrote:Personally I've noticed that complex SLFs can slow down at times (because the engine's SLF implementation isn't very efficient).
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
Re: tekelili WML noob questions
SLF = StandardLocationFilter.
UMC Story Images — Story images for your campaign!
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
I suppose that wouldn't help. Pretty unsure though.SlowThinker wrote:if the addon contains its base WML code and contains many scenarios, the base WML is repeated in each scenario, and so the WML code becomes very bloated. I suppose I can avoid this if I put all the base WML code (i.e. the code that is common for all scenarios) into an era? Am I right? (I guess that measure won't decrease the size of saves thought)
The [event]s an era contains are added to the scenario events and saved with it. I suppose that happens when the scenario is preprocessed, which happens only on the host, and then the whole scenario gets sent to the remote clients. What gets sent should be quite similar to a savegame. The events from a require_era=no era are sent to the remote clients (which don't have the era) as well so it must be about this way.
Only 1 era can be used in a MP game at the same time unfortunately. So what people do is that they create an additional era within their addon for each foreign era they want to support which adds support for the combination of the own and the foreign era. At least that's how Diplomacy Era, myself (PYAE) and Debug Era do it.SlowThinker wrote:But now what to do if I need to use another external era(s) with my add-on? Can I include the file with the external_era into the code of my_addon_era?
Including the foreign era's code may be possible (depends on the structure of the foreign code).
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
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: tekelili WML noob questions
You mean they copy the code from Diplomacy era and customize it?Anonymissimus wrote:1 era can be used in a MP game at the same time unfortunately. So what people do is that they create an additional era within their addon for each foreign era they want to support which adds support for the combination of the own and the foreign era. At least that's how Diplomacy Era, myself (PYAE) and Debug Era do it.
Yes, a foreign code fragmented into many files is better.Anonymissimus wrote:Including the foreign era's code may be possible (depends on the structure of the foreign code).
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
No. Unless it's impossible to reference it somehow.SlowThinker wrote:SlowThinker wrote:You mean they copy the code from Diplomacy era and customize it?
So what I do is for instance
Code: Select all
[era]
...
require_era=no
{ERA_DEFAULT}
{ERA_PYA}
[/era]
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
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: tekelili WML noob questions
The advantage/disavantage of the reference is your add-on follows the changes done in new versions of the foreign era.
BTW I would like if WML allowed labels in the tags, like [add=my_label]. It could allowSlowThinker wrote:Yes, a foreign code fragmented into many files is better.
- to include an individual tag from the referenced file
- to obtain an easier access deep into a variable: Now if you want to edit a code that is supposed to be applied by insert_tag then you must apply set_variable to filter[4].not[0].add[10].radius
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
Re: tekelili WML noob questions
I want calculate this function: y=(5/6)^((x-1)/(x^(5/12)))
I guess I should use lua for that... if that is true, as I have no clue about it I wonder if anyone could give me the very code I should copy paste to calculate $y using $x
I guess I should use lua for that... if that is true, as I have no clue about it I wonder if anyone could give me the very code I should copy paste to calculate $y using $x
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: tekelili WML noob questions
You can use Lua for this, of course, but unless I misunderstand what you want, you do not need to. You just put your equation inside
$( )
. For example, here's a moveto event that takes the unit's x coordinate and calculates the respective y from your function:
Code: Select all
[event]
name=moveto
first_time_only=no
[set_variable]
name=y
value=$( (5./6.)^(($unit.x-1)/($unit.x^(5./12.))) )
[/set_variable]
{MESSAGE $unit.id "" "" "y= $y"}
[/event]
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: tekelili WML noob questions
don't forget to put your $(...) inside a "..."
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: tekelili WML noob questions
ty a lot guys for help, and sorry for silly question. I sometimes become ofuscated by the easiest problems
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II