Heindals WML Questions

The place to post your WML questions and answers.

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

Re: Heindals WML Questions

Post by Dugi »

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: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Heindal
Posts: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Heindal
Posts: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Heindals WML Questions

Post by Dugi »

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: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Heindals WML Questions

Post by Elvish_Hunter »

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, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
JaMiT
Inactive Developer
Posts: 511
Joined: January 22nd, 2012, 12:38 am

Re: Heindals WML Questions

Post by JaMiT »

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 »

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: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Heindal
Posts: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Heindals WML Questions

Post by Crendgrim »

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
Location: The past

Re: Heindals WML Questions

Post by 8680 »

Crendgrim wrote:I'm not sure whether {FOREACH} works inside of [message], though.
It doesn’t.
User avatar
Heindal
Posts: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Heindals WML Questions

Post by Heindal »

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, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Heindals WML Questions

Post by 8680 »

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