Heindals WML Questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.
User avatar
Dugi
Posts: 4843
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Heindals WML Questions

Post by Dugi » November 27th, 2012, 12:08 am

Check out what is in stderr.txt in Program Files/Battle for Wesnoth 1.10.X, it should give you an idea what is actually the cause.

To make an overlay with terrain, do this (I suppose you know how to edit it to suit your needs):

Code: Select all

{OVERLAY             *^Ychr  overlays/chair.png}
[terrain_type]
    symbol_image=overlays/chair   #This must be in /images/terrain/, omit .png
    id=wesmmo_overlay_chair
    editor_name= _ "Chair"
    string=^Ychr
    aliasof=_bas   #This makes it have no effect on the terrain's gameplay properties, only graphical ones
    editor_group=wesnoth-UMC-WesMMO
[/terrain_type]

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » November 27th, 2012, 5:48 pm

Alarantalara: Thanks for your reply.

Dugi: thanks for showing me, but I already figured that out and I already saved a map with around 7 pieces of furniture for our mmorpg, but I wanted to add more furniture and some interactive elements (the 'beds' will heal the heros). I think its a problem with the ids as Alarantalara said.

Unfortunately I don't have time this evening, I will post my results tomorrow.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » November 28th, 2012, 8:23 pm

The crash of the map editor was caused by "string" for an overlay that was longer than five letters. It works fine now.

e.g.

Code: Select all

[terrain_type]
    symbol_image=furniture/wooden-door-se
    id=wooden-door-se
    name= _ "Wooden Door SE Overlay"
    string=^Zdseo
    aliasof=Xv
    heals=0
    gives_income=false
    editor_group=MMORPG
[/terrain_type]
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » January 9th, 2013, 11:14 pm

There still one serious problem in all my rpg campaigns and I want to get rid of that. Its something trivial, but I can't really figure this one out. If the character has below 100 gold and enters a new map, he will get 100 gp each time in the next map, as in Standard Wesnoth you will always start with this minimum. Is there an easy way to retset this minimum to what-i-know 0?

I have used macros to go to other maps like:

Code: Select all

[endlevel]
	result=victory
	next_scenario={NEXT_SCENARIO}
	save=no
	carryover_report=no
	carryover_percentage=100
	linger_mode=no
	bonus=no
[/endlevel]

I have saved the gold variable when leaving the map.

1. "Solution": I set the scenario gold to 0 (within side defintion) and added the saved gold variable to the players gold.

Result: 100 Gold.

2. Solution: I tried to set the gold dircetly within the side definition by using gold=$gold

Result: 100 Gold.

These were my solutions and I'm pretty sure that at least the first should work, but it seems that the minimum will always overwrite the so saved player gold.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Dugi
Posts: 4843
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Heindals WML Questions

Post by Dugi » January 10th, 2013, 11:17 am

1. "Solution": I set the scenario gold to 0 (within side defintion) and added the saved gold variable to the players gold.

Result: 100 Gold.
Strange, it always worked for me. Or I just thought it worked.

There is of course a workaround, in a prestart event, you can use store_side or some other direct actions related to gold (reading the wiki again might be worth the time) to set the side's gold manually to a certain amount (you have already saved in a variable named gold).

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » January 10th, 2013, 8:37 pm

Ok, I will give it a try. I used a prestart and start event, but maybe there was some mistake - so I will recheck that.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Elvish_Hunter
Developer
Posts: 1375
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Heindals WML Questions

Post by Elvish_Hunter » January 11th, 2013, 10:31 am

Heindal wrote:I have saved the gold variable when leaving the map.

1. "Solution": I set the scenario gold to 0 (within side defintion) and added the saved gold variable to the players gold.

Result: 100 Gold.

2. Solution: I tried to set the gold dircetly within the side definition by using gold=$gold

Result: 100 Gold.
Assuming that you stored the gold in a variable called stored_gold, you can try with [modify_side]:

Code: Select all

[modify_side]
    side=1
    gold=$stored_gold
[/modify_side]
Current maintainer of these add-ons:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons
Active again until mid-October

JaMiT
Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Heindals WML Questions

Post by JaMiT » January 17th, 2013, 2:47 am

Heindal wrote:2. Solution: I tried to set the gold dircetly within the side definition by using gold=$gold
Variables cannot be used directly within a side definition. But this gave you 100 gold instead of 0? That doesn't seem right.

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Heindals WML Questions

Post by Max » January 17th, 2013, 5:23 am

there's some default gold (100) for a side hard-coded in the source. it don't think it was meant to define minimum gold for a side but it might leak through in certain situations...

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » January 18th, 2013, 11:54 pm

Thank you all for your replies.

The approach of Elvish_Hunter works fine, so if anybody else encounters the problem modify side within a prestart event is the solution.

JaMiT - I proably tried both solutions at the same time. That variables can't be defined in the side definition sounds familiar, but I gave it try. Its likely that it was completly ignored and something else caused the 100 starting gold. Took me a while to clean the source code up.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » January 22nd, 2013, 10:51 pm

Annother issue. I have a Junk Store in some of my rpgs, a Junk Store will buy all available items. This is so far done with a simple option structure. There is an option for each object that can be sold. The idea is to automatize the whole procedure by using a comma seperated list.

The first attempt was to realize that with the rand function, taking one of the elements, change the list taking away the diced object and than dice again within a while loop until the list is empty. So far I'm not quite sure if you can use "while" here, as we are talking about option and the option will just show until the while loop exist, which will end itself.

My next attempt was to use For each and set variables. But I don't have any experience with that and after several tries and reading through source code and wiki entries, not finding what I'm looking for I figured out the following "solution". It doesn't work however.

Spoiler:

Can anybody give me a hint how to realize that?
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Heindals WML Questions

Post by Crendgrim » January 22nd, 2013, 11:08 pm

Note that it's been quite some time since I last coded WML. However, I think (!) there are two problems with that code:
1. IIRC, it should read {FOREACH objects i}
2. You are calling [option] tags without a [message] tag around them, which does not work.
I'm not sure whether {FOREACH} works inside of [message], though. If not, you might need to do some magic with [insert_tag].
UMC Story Images — Story images for your campaign!

User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm

Re: Heindals WML Questions

Post by 8680 » January 22nd, 2013, 11:25 pm

Crendgrim wrote:I'm not sure whether {FOREACH} works inside of [message], though.
It doesn’t.

User avatar
Heindal
Posts: 893
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: Heindals WML Questions

Post by Heindal » January 25th, 2013, 3:34 pm

Hm, thanks both of you for this information. Maybe I should try to use a nested while event then. While should work with "option", after all that is how dialogues and shops are realized. I will think of a workaround!

btw: thanks to dugi - he told how to use "split" and set variables so I could research the rest in the wiki.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm

Re: Heindals WML Questions

Post by 8680 » January 25th, 2013, 6:23 pm

Heindal wrote:Maybe I should try to use a nested while event then.
If you mean simply replacing the {FOREACH} with a [while], that won’t work, because {FOREACH} is a [while] under the macro. I expect this will require use of [insert_tag], as Crendgrim mentioned.

Post Reply