build village

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
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

build village

Post by ERROR1025 »

I hope use [set_menu_item] add a "use 14 gold build village on map any" and "have build village",but WML is not work
use village WML in build.cfg and ANL.cfg(use ANL define)
edit:
and i hope player can any time(only need in player turn) give other player village,but I have absolutely no idea how to do it.(Alliances_Mod not have reference)
Attachments
ProWesnothStart-modf.zip
(1.79 KiB) Downloaded 48 times
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

Did you post all your files? I don't see an event tag that activates the code in build.cfg. The [set_menu_item] tag must go inside an [event] tag. You can use a prestart event for this. Also, you have $x, $y, and $side in build.cfg, but I don't see any place where these variables were defined.

In the future, please don't tell us that "the WML doesn't work." Tell us what you want to happen, and what actually happens.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 6th, 2024, 6:46 am Did you post all your files? I don't see an event tag that activates the code in build.cfg. The [set_menu_item] tag must go inside an [event] tag. You can use a prestart event for this. Also, you have $x, $y, and $side in build.cfg, but I don't see any place where these variables were defined.

In the future, please don't tell us that "the WML doesn't work." Tell us what you want to happen, and what actually happens.
in mian cfg start:

{~add-ons/ProWesnothStart-modf/ANL.cfg}
{~add-ons/ProWesnothStart-modf/ability.cfg}
{~add-ons/ProWesnothStart-modf/build.cfg}
i try use $x $y $side get player's side and hex,or is need other WML?
add [event] can not work,and game report bug:
[if] didn't find any [then],[elseif],or [else] children.
i know the report is expected(use change Gold/V WML)
not have other bug info.
For the needs behind "edit", I need similar WML reference,i don't know how do it.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

ERROR1025 wrote: January 6th, 2024, 7:15 am {~add-ons/ProWesnothStart-modf/build.cfg}
This line adds the code to your project, but it doesn't run that code. The code must be in an [event]. Otherwise, the code will never run.
ERROR1025 wrote: January 6th, 2024, 7:15 am game report bug:
[if] didn't find any [then],[elseif],or [else] children.
This is not related to a new event, it is a problem with every [event] in main. The simplest [if] tag must look like this:

Code: Select all

[if]
	# condition
	[then]
		# commands to run when the condition is true
	[/then]
[/if]
I know you have other problems, but you need to make _main.cfg run without errors first, then you need to make the menu item appear. When that works correctly, you can focus on the next problems.
ERROR1025 wrote: January 6th, 2024, 7:15 am i try use $x $y $side get player's side and hex,or is need other WML?
The side currently playing is stored in $side_number, not $side. Inside [set_menu_item], the hex the user selected in stored in $x1 and $y1, not $x and $y. But, this information is not useful until you get the menu item to appear.

Edit: I should also mention that the code for the sliders is going to do nonsensical things, even if you fix the errors so that _main.cfg can run. You should probably just remove the slider events for now so you can focus on the menu item. That is the easier problem to fix.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 6th, 2024, 7:55 am
ERROR1025 wrote: January 6th, 2024, 7:15 am {~add-ons/ProWesnothStart-modf/build.cfg}
This line adds the code to your project, but it doesn't run that code. The code must be in an [event]. Otherwise, the code will never run.
ERROR1025 wrote: January 6th, 2024, 7:15 am game report bug:
[if] didn't find any [then],[elseif],or [else] children.
This is not related to a new event, it is a problem with every [event] in main. The simplest [if] tag must look like this:

Code: Select all

[if]
	# condition
	[then]
		# commands to run when the condition is true
	[/then]
[/if]
I know you have other problems, but you need to make _main.cfg run without errors first, then you need to make the menu item appear. When that works correctly, you can focus on the next problems.
ERROR1025 wrote: January 6th, 2024, 7:15 am i try use $x $y $side get player's side and hex,or is need other WML?
The side currently playing is stored in $side_number, not $side. Inside [set_menu_item], the hex the user selected in stored in $x1 and $y1, not $x and $y. But, this information is not useful until you get the menu item to appear.

Code: Select all

#define BUILD_V
        {MODIFY_TERRAIN_OVERLAY "^Vh" $x1 $y1}
        [capture_village]
            x=$x1
            y=$y1
            side=$side_number
        [/capture_village]
        # The Flag for the village will be added immediately.
        # The then macro will explicitely cause delays for half a second to play sounds.
        # Redrawing here, so that the terrain will be redrawn at the same time when the flag is placed.
        [redraw][/redraw]
#enddef
[event]
name=prestart
first_time_only=no
id=BV
[set_menu_item]
	id=build_v
	description=_"Build V"
	#[filter_location]
	#[/filter_location]
	[command]
		[if]
			[variable]
				name=gold
				Greater_than_equal_to=14
			[/variable]
		[then]
			[gold]
				amount=-14
				side=$side_number
			[/gold]
				{BUILD_V}
		[/then]
			[else]
				[message]
				speaker=narrator
				message=_"You don't have enough gold to build V."
				[/message]
			[/else]
		[/if]
	[/command]
[/set_menu_item]
[/event]
is work,but is can not work:if gold <14,player can build villvge(i need block player gold < 14 build)
and auto delete forest,if have forest in hex,i hope only add villvge
User avatar
Ravana
Forum Moderator
Posts: 3017
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: build village

Post by Ravana »

Greater_than_equal_to is not recognized key of [variable].
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

Ravana wrote: January 6th, 2024, 2:15 pm Greater_than_equal_to is not recognized key of [variable].
you sure?wiki have
https://wiki.wesnoth.org/ConditionalAct ... ariable.5D
if it,how check gold >= 14?
User avatar
Ravana
Forum Moderator
Posts: 3017
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: build village

Post by Ravana »

That one has greater_than_equal_to but no Greater_than_equal_to.

You also need to somehow fill variable of gold, possibly by storing.
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

How get play gold?use value=$side_number.gold in event not work.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

You should go to the wiki and read the list of the tags that are available on the right side of the screen. That works better than guessing, which seems to be your current method. One of the tags in the list is [store_gold]. You can use something like this:

Code: Select all

[store_gold]
	side=$side_number
	variable=current_sides_gold
[/store_gold]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 7th, 2024, 4:34 am You should go to the wiki and read the list of the tags that are available on the right side of the screen. That works better than guessing, which seems to be your current method. One of the tags in the list is [store_gold]. You can use something like this:

Code: Select all

[store_gold]
	side=$side_number
	variable=current_sides_gold
[/store_gold]
Ok,is work,but auto delete forest,if have forest in build hex,i hope only add villvge.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

ERROR1025 wrote: January 7th, 2024, 5:06 am Ok,is work,but auto delete forest,if have forest in build hex,i hope only add villvge.
Wouldn't a person cut down trees to build a house?

You seem to want one hex to be forest and village at the same time, which can't happen in the game. There must be separate terrains in each hex. If you mean that you want to see a building with trees surrounding it very close to its walls, you would need to draw that yourself, and create terrain codes for it too. I don't think anyone has done this before because it would be a lot of work: There would be thousands of possibilities of tree and building types mixed together, and it wouldn't really benefit the game very much.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 7th, 2024, 5:48 am
ERROR1025 wrote: January 7th, 2024, 5:06 am Ok,is work,but auto delete forest,if have forest in build hex,i hope only add villvge.
Wouldn't a person cut down trees to build a house?

You seem to want one hex to be forest and village at the same time, which can't happen in the game. There must be separate terrains in each hex. If you mean that you want to see a building with trees surrounding it very close to its walls, you would need to draw that yourself, and create terrain codes for it too. I don't think anyone has done this before because it would be a lot of work: There would be thousands of possibilities of tree and building types mixed together, and it wouldn't really benefit the game very much.
I use code check variable ovwer
var GVL:

Code: Select all

		[store_locations]
			x=$x1
			y=$y1
			variable=GVL
		[/store_locations]
Use GVL:

Code: Select all

            [variable]
                name=side_number
                numerical_equals=$GVL.owner_side
            [/variable]
But can not check owner(if have the code,all is false ,else not have the code,all is true)how fix?
I'm read wiki [store_locations] and [if] but can not fix.
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: build village

Post by beetlenaut »

The code you posted works. The error must be somewhere else. If you post the whole scenario, we will probably be able to find it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: build village

Post by ERROR1025 »

beetlenaut wrote: January 7th, 2024, 8:17 am The code you posted works. The error must be somewhere else. If you post the whole scenario, we will probably be able to find it.
This full add-on file,BUG code in give.cfg
Attachments
ProWesnothStart-modf.zip
(3.55 KiB) Downloaded 28 times
Post Reply