Macro/file is missing

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
B099
Posts: 26
Joined: September 5th, 2024, 1:00 pm

Macro/file is missing

Post by B099 »

The following is code I copypasted from the wiki.

for i,loc in ipairs(wesnoth.map.find{terrain = "Gg"}) do
wesnoth.current.map[loc] = "Rr"
end


The error: Macro/file 'terrain' is missing

Tracestack:

[multiplayer]->[event](preload)->[lua]

I suspect that scenario and/or preload has something to do with this, because similiar code works fine in other addons.
User avatar
Celtic_Minstrel
Developer
Posts: 2371
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Macro/file is missing

Post by Celtic_Minstrel »

You haven't shown your full code, so it's difficult to be sure of what you're doing. However, most likely the solution is this:

Code: Select all

[lua]
	code=<<
		for i,loc in ipairs(wesnoth.map.find{terrain = "Gg"}) do
			wesnoth.current.map[loc] = "Rr"
		end
	>>
[/lua]
The key point is the use of << and >> to let the WML preprocessor know that {terrain = "Gg"} is not a macro and should be left alone.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
B099
Posts: 26
Joined: September 5th, 2024, 1:00 pm

Re: Macro/file is missing

Post by B099 »

Wow, that was easy solved thank you
Post Reply