Help figuring out lua errors

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Help figuring out lua errors

#1 Post by Goblinz »

At the moment I am trying to make a class that has the ability to summon trees. I am basing the talent off the Summon Ice wall ability. the error I am getting is:
"lua error:/engine/interface/Game Targeting.lua:124: data/talent/gifts/wrath.lua:98: attempt to index global 'Object' (a nil value)

Here is the code for the talent in question:

Code: Select all

newTalent{
	name = "tree growth",
	type = {"wild-gift/wrath", 3},
	require = gifts_req3,
	points = 5,
	random_ego = "defensive",
	equilibrium = 10,
	cooldown = 30,
	range = 10,
	tactical = { DISABLE = 2 },
	requires_target = true,
	action = function(self, t)
		local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
		local x, y = self:getTarget(tg)
		if not x or not y then return nil end
		local _ _, x, y = self:canProject(tg, x, y)
		if game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move") then return nil end

		local e = Object.new{
			old_feat = game.level.map(x, y, Map.TERRAIN),
			name = "summoned Tree",
			display = '#', color=colors.LIGHT_BLUE, back_color=colors.BLUE,
			always_remember = true,
			can_pass = {pass_wall=1},
			block_move = true,
			block_sight = true,
			temporary = 4 + self:getTalentLevel(t),
			x = x, y = y,
			canAct = false,
			act = function(self)
				self:useEnergy()
				self.temporary = self.temporary - 1
				if self.temporary <= 0 then
					game.level.map(self.x, self.y, engine.Map.TERRAIN, self.old_feat)
					game.level:removeEntity(self)
					game.level.map:redisplay()
				end
			end,
			summoner_gain_exp = true,
			summoner = self,
		}
		game.level:addEntity(e)
		game.level.map(x, y, Map.TERRAIN, e)
		return true
	end,
	info = function(self, t)
		return ([[Summons an tree for %d turns.]]):format(4 + self:getTalentLevel(t))
	end,
}
all but 2-3 lines of code is copied from Ice wall and what I changed has nothing to do with targeting. Any advice on how to fix this or how debug in more detail would be welcome.
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Susramanian
Spiderkin
Posts: 454
Joined: Sat May 15, 2010 3:09 am

Re: Help figuring out lua errors

#2 Post by Susramanian »

My knowledge of lua is abysmal, but I've been slowly learning my way around the ToME code. Looking at the cold-drake.lua file, I see this line at the top:

Code: Select all

local Object = require "engine.Object"
My first guess is that you don't have this line at the top of your wrath.lua file.
If that's not it, I have no idea!

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: Help figuring out lua errors

#3 Post by Goblinz »

I completely missed that when looking at the diff. But it worked Thank you for your aid.
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: Help figuring out lua errors

#4 Post by Goblinz »

I am getting this error and I have no idea what is causing it

Code: Select all

Lua Error: /engine/interface/ActorTalents.lua:32: /data/talents/gifts/hunting.lua:59: nesting of [[...]] is deprecated near '['
	At [C]:-1 
	At [C]:-1 error
	At /engine/interface/ActorTalents.lua:32 loadDefinition
	At /engine/interface/ActorTalents.lua:40 load
	At /data/talents/gifts/gifts.lua:135 f
	At /engine/interface/ActorTalents.lua:42 loadDefinition
	At /engine/interface/ActorTalents.lua:40 load
	At /data/talents.lua:67 f
	At /engine/interface/ActorTalents.lua:42 loadDefinition
	At /mod/load.lua:104 
	At [C]:-1 require
	At /engine/Module.lua:137 load
	At /engine/Module.lua:245 instanciate
	At /engine/utils.lua:948 showMainMenu
	At /engine/init.lua:112 
	At [C]:-1 dofile
	At /loader/init.lua:133 
and here is the code of the talent that probably has the error

Code: Select all

newTalent{
	name = "Reducing Arrow",
	type = {"wild-gift/hunting", 2},
	require = gifts_req2,
	points = 5,
	stamina = 5,
	cooldown = 10,
	tactical = { DISABLE = 4 },
	range = archery_range,
	requires_target = true,
	on_pre_use = function(self, t, silent) if not self:hasArcheryWeapon() then if not silent then game.logPlayer(self, "You require a bow or sling for this talent.") end return false end return true end,
	action = function(self, t)		
		self:incEquilibrium(-self:getTalentLevel(t)*3)
		if self:getTalentLevel(t) > 3 then
			local targets = self:archeryAcquireTargets({type="beam"}, {one_shot=true})
			if not targets then return end
			self:archeryShoot(targets, t, {type="beam"}, {mult=self:combatTalentWeaponDamage(t, 0.5, 1.2), damtype=DamageType.ACID_BLIND})
			return true
		end
		local targets = self:archeryAcquireTargets(nil, {one_shot=true})
		if not targets then return end
		self:archeryShoot(targets, t, nil, {mult=self:combatTalentWeaponDamage(t, 0.5, 1.2), damtype=DamageType.ACID_BLIND})
		return true
	end,
	info = function(self, t)
		return ([[A steady shot, doing %d%% damage.]]):format(self:combatTalentWeaponDamage(t, 1.1, 2.2) * 100)
	end,
}
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Help figuring out lua errors

#5 Post by Grey »

It would help if you could point out which is line 59, as reported in the error.

However it seems fairly clear that you should be using "" instead of [[]] in the return line near the end.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: Help figuring out lua errors

#6 Post by Goblinz »

Whoops I was looking at the wrong file. The error is then obvious. Thanks for your consideration.
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Post Reply