on_event context does not give me

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

Moderator: Forum Moderators

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

on_event context does not give me

Post by B099 »

Hi, my code here:

Code: Select all

local function attack_start_event(ctx)
    less_random_tmp_att = ctx.weapon.damage
    less_random_tmp_def = ctx.second_weapon.damage
end

on_event("attack", attack_start_event)
The error says that "weapon" is a nil value. It also said so if i "data" is a nil value i tried "ctx.data.weapon.damage".
Can somebody help mE?
Soliton
Site Administrator
Posts: 1731
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: on_event context does not give me

Post by Soliton »

You can look at ctx with wesnoth.interface.add_chat_message(wesnoth.as_text(ctx)) then you'll probably see that it is not the lua table you expected. You might want to use the wml module to work with it.
"If gameplay requires it, they can be made to live on Venus." -- scott
B099
Posts: 26
Joined: September 5th, 2024, 1:00 pm

Re: on_event context does not give me

Post by B099 »

Thank you for the help!!!
Post Reply