Need help with coding a shop into a map.

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.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Need help with coding a shop into a map.

Post by Neko5Chan »

So I just began WML and also doing a map but the game internet page (a shop thingy) doesn t help all that much. I wanna put a unit to act as a shop and sell a bunch of stuff that modify different adjectives or comlletly heals ur unit. If someone can explain would help a lot thx in advance.
User avatar
EarthCake
Posts: 376
Joined: March 29th, 2019, 1:57 pm
Location: The Wall

Re: Need help with coding a shop into a map.

Post by EarthCake »

You can take a look into Legend of the Invincibles for code. It is hard to find a scenario with it though. Nevermind, if this doesn't help, I will later make the detailed explanation.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

Ok I am gonna download tommorow Loti cuz it s late here where I live. And try to analize the files, maybe come back here if I need more help.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

An explanation would too come in handy for future reference. Thx a lot
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Need help with coding a shop into a map.

Post by Ravana »

I doubt LotI is useful for beginning. Colosseum should be most simple case of shop.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

Well I was looking in Creep wars for an example but it s way more complicated than expected. :)
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Need help with coding a shop into a map.

Post by Ravana »

Creep war was decently understandable at 0.2, but 0.3 uses Lua.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

Yes thats why I find it hard to understand because of the lua coding. Is not that I didn t used lua in the past but Company of Heroes 2 uses very basic lua coding for a weather file in maps with different atributes and textures so u kinda have everything wrote in a .lua file in the core game files :). So my lua knowledge is basic although I worked a small bit.
Shiki
Developer
Posts: 344
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Need help with coding a shop into a map.

Post by Shiki »

You can actually include the Colosseum Shop into another add-on, by

Code: Select all

# reading the macros with
{~add-ons/Colosseum3p/macros/upgrade.cfg}

# and using them inside a scenario / era
{UPGRADED_FEEDING_EVENT}
{COLOSSEUM_UPGRADE 2,20,33 8,3,44} # same shop at several locations
That might be nice to get something working at first, and also has a few bits of Lua in it. But read below …
Well I was looking in Creep wars for an example but it s way more complicated than expected. :)
I share that experience (part of the reason why Colosseum and A new Land aren't using Lua).

Nevertheless, in the long run, Lua offers more for shop-systems. Until wesnoth 1.12, all shop systems were based upon using the WML tag [message] (wesnoth.show_message_dialog being the Lua counterpart). With wesnoth 1.14, one can, by using Lua, also display dialogues in the style like the recruit dialogue and all that. CreepWar uses wesnoth.show_dialogue (Documentation) — and is the only add-on I know that upgraded it's shop code to 1.14 standards.

A smaller example is the dialogue at the start of wesnoth's tutorial (whether you want to play Konrad or Li'sar).
That's scary to look at, around 70 lines of code for a small dialogue box. However, looking closer at it, all the mess belongs to T.grid… whatever that may mean, if we ignore that part, it suddenly looks a lot more readable.
A huge part of the Creep_War_Dev/lua/shop/shop_menu.lua is used to describe the layouting, and helper functions — things, which aren't really of interest until we are at the point of having a window appearing.
Try out the dark board theme.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

Ok the idea with implementing the colosseum shop is good I might try that but I wanna ask something how to separate the location of each shop. Like I put for example 23 45, or I just say 2, 3, 4, 70,34 and the game decides what is what. Also a good mod for items on map that add attacks or different atributes :mrgreen:. Just a small sample that is easily reusable if not maybe a scenario that has them, I was thinking at Heir to the throne with the fire scepter but idk.
User avatar
octalot
General Code Maintainer
Posts: 777
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: Need help with coding a shop into a map.

Post by octalot »

Neko5Chan wrote: June 30th, 2019, 3:07 pm Also a good mod for items on map that add attacks or different atributes :mrgreen:. Just a small sample that is easily reusable
The Storm Trident, Holy Water and a few other objects are provided in the core macro utilities, which you can use in any scenario.
Definition is at https://raw.githubusercontent.com/wesno ... /items.cfg
Example usage, placing 3 of them in Delfadors Memoirs' scenario "14_Shadows":

Code: Select all

{OBJ_POTION_HOLY 16 5  shadows_holywater1}
{OBJ_POTION_HOLY 32 5  shadows_holywater2}
{OBJ_POTION_HOLY 20 10 shadows_holywater3}
Dead Water has a better version of the Storm Trident, which also adds a unit_overlay so it's easy to see which unit has it, and this overlay also shows up in the recall dialog.

The Black Cross of Aleron has a huge selection of overlay icons and abilities.

Heir to the Throne's Sceptre is a complex case that's only usable when a few unit types can pick up an item. In Konrad and Li'sar's unit_types there's a variation if they pick up the Sceptre, which is the same mechanism used for the Walking Corpse's different unit types.
Shiki
Developer
Posts: 344
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Need help with coding a shop into a map.

Post by Shiki »

With macros, a space separates different macro "arguments"
{COLOSSEUM_UPGRADE 1 5} # places at x,y=1,5
but x and y can be a comma separated list — so
{COLOSSEUM_UPGRADE 2,20,33 8,3,44} # will be the coordinates 2,8 20,3 and 33,44
Try out the dark board theme.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

The following add-on had errors and could not be loaded:
/storage/emulated/0/Android/data/it.alessandropira.wesnoth114/files/.wesnoth1.14/data/add-ons/Octo_Mappack/_main.cfg

Please report this to the author or maintainer of this add-on.

Details:

Macro/file 'COLOSSEUM_UPGRADE' is missing
at ~add-ons/Octo_Mappack/scenarios/8p_Valley_of_the_Ancients.cfg:71
included from ~add-ons/Octo_Mappack/_main.cfg:15



I don t understand why wesnoth keeps giving me this error.
User avatar
octalot
General Code Maintainer
Posts: 777
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: Need help with coding a shop into a map.

Post by octalot »

You need to tell Wesnoth to read the definition of COLOSSEUM_UPGRADE, which is described in the Colosseum add-on's Colosseum3p/readme file.

There's a bug in that readme (in version 1.6.4), the line to include should read {~add-ons/Colosseum3p/macros/upgrade.cfg}.
Neko5Chan
Posts: 10
Joined: July 4th, 2018, 9:29 pm

Re: Need help with coding a shop into a map.

Post by Neko5Chan »

Ohhh thanks lemme try that.
Post Reply