Need help with coding a shop into a map.
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.
Need help with coding a shop into a map.
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.
Re: Need help with coding a shop into a map.
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.
Re: Need help with coding a shop into a map.
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.
Re: Need help with coding a shop into a map.
An explanation would too come in handy for future reference. Thx a lot
Re: Need help with coding a shop into a map.
I doubt LotI is useful for beginning. Colosseum should be most simple case of shop.
Re: Need help with coding a shop into a map.
Well I was looking in Creep wars for an example but it s way more complicated than expected.
Re: Need help with coding a shop into a map.
Creep war was decently understandable at 0.2, but 0.3 uses Lua.
Re: Need help with coding a shop into a map.
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.
Re: Need help with coding a shop into a map.
You can actually include the Colosseum Shop into another add-on, by
That might be nice to get something working at first, and also has a few bits of Lua in it. But read below …
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.
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
I share that experience (part of the reason why Colosseum and A new Land aren't using Lua).Well I was looking in Creep wars for an example but it s way more complicated than expected.
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.
Re: Need help with coding a shop into a map.
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 . 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.
Re: Need help with coding a shop into a map.
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}
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_type
s there's a variation
if they pick up the Sceptre, which is the same mechanism used for the Walking Corpse's different unit types.Re: Need help with coding a shop into a map.
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
{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.
Re: Need help with coding a shop into a map.
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.
/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.
Re: Need help with coding a shop into a map.
You need to tell Wesnoth to read the definition of COLOSSEUM_UPGRADE, which is described in the Colosseum add-on's
There's a bug in that readme (in version 1.6.4), the line to include should read
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}
.Re: Need help with coding a shop into a map.
Ohhh thanks lemme try that.