Creating new unit statuses and getting them to show
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.
Re: Creating new unit statuses and getting them to show
I tested it out in a campaign and it doesn't work. Here is how I use it:
I only use it in one scenario, so I place it toplevel in that scenario. When I access the scenario, I get this error:
Code: Select all
#define POSSESSION
[event]
name=preload
first_time_only=no
[lua]
code=<<
local _ = wesnoth.textdomain "wesnoth-SR"
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.possessed then
table.insert(s, { "element", {
image = "misc/waypoint.png",
tooltip = _"possessed: This unit has been possessed. It will be temporarily under control of its possessor's side until the magic wears off."
} })
end
return s
end
>>
[/lua]
[/event]
#enddef
I checked, and I'm calling it right and everything... Does anyone have any ideas of the problem?stderr.txt wrote:error scripting/lua: [string "..."]:3: attempt to index field 'theme_items' (a nil value)
stack traceback:
[string "..."]:3: in function 'bytecode'
...L/Desktop/WolfQuest/Wesnoth1.9/data/lua/wml-tags.lua:206: in function 'cmd'
...L/Desktop/WolfQuest/Wesnoth1.9/data/lua/wml-tags.lua:220: in function <...L/Desktop/WolfQuest/Wesnoth1.9/data/lua/wml-tags.lua:213>
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Creating new unit statuses and getting them to show
Apparently your BfW version isn't new enough. You need 1.9.4 or greater. wesnoth.theme_items isn't nil for me.
EDIT
Perhaps you need even 1.9.5, the theme_items proxy table wasn't created immediately.
EDIT2
Well, no, 1.9.4 must be sufficient.
EDIT
Perhaps you need even 1.9.5, the theme_items proxy table wasn't created immediately.
EDIT2
Well, no, 1.9.4 must be sufficient.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
- Elvish_Hunter
- Posts: 1576
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Creating new unit statuses and getting them to show
A sort-of thread necromancy...
In the first post of this topic, silene said that the code to show the status icon should be placed in a preload event. This has the disadvantage to require modifying every scenario where you need to display your custom status.
In trunk, commits [rev]55393[/rev] and [rev]55394[/rev], I added support for stunned status icon in Dead Water and Under the Burning Suns. However, the approach that I used is different: instead of modifying every scenario, I added a [lua] tag directly in the _main.cfg, guarded by the campaign's #ifdef.
This is the code now available in DW's _main.cfg:At least for single player campaigns, there is this alternative way that does not require modifying every scenario.
In the first post of this topic, silene said that the code to show the status icon should be placed in a preload event. This has the disadvantage to require modifying every scenario where you need to display your custom status.
In trunk, commits [rev]55393[/rev] and [rev]55394[/rev], I added support for stunned status icon in Dead Water and Under the Burning Suns. However, the approach that I used is different: instead of modifying every scenario, I added a [lua] tag directly in the _main.cfg, guarded by the campaign's #ifdef.
This is the code now available in DW's _main.cfg:
Code: Select all
[lua]
code=<<
local _ = wesnoth.textdomain "wesnoth-dw"
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.stunned then
table.insert(s, { "element", { image = "misc/stunned-status-icon.png",
tooltip = _"stunned: This unit is stunned. It cannot enforce its Zone of Control."
} } )
end
return s
end
>>
[/lua]
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)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: Creating new unit statuses and getting them to show
Is there a way to make these statuses also colourise the units like poison and slow does? It is quite annoying to do it with [objects] with image_mod.
Re: Creating new unit statuses and getting them to show
I have a problem with the icons. When I use an icon for a status (made the same size as the poison and slows icon) the game seems to stretch the image. How can I fix this?