Or inside LUA, not exe : -- Define the NPC class
local NPC = {}
-- Constructor function to create a new NPC object
function NPC:new(name)
-- Create a new instance of the NPC class
local npc = {
name = name,
knowledge = {}
}
-- Define the speak method
function npc:speak(message)
print(self.name .. " says: " .. message)
end
-- Define the learn method
function npc:learn(topic, information)
self.knowledge[topic] = information
end
-- Return the created NPC object
return npc
end
-- Create a new NPC object
local npc = NPC:new("NPC")
-- Example usage
npc:speak("Hello, I am an NPC!")
npc:learn("Lua programming", "Lua is a powerful scripting language.")
-- Access the learned information
print(npc.knowledge["Lua programming"])