Add inventory slots line to example module. It crashes.

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Add inventory slots line to example module. It crashes.

#1 Post by Psiweapon »

So I tried to add a line from the guides to the example module

body = { INVEN = 1000, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },

To the base player descriptor. It makes the module crash or hang after role selection.

Anybody got any idea why?

The error message talks about engine lua files, not module lua files.

Castler
Thalore
Posts: 153
Joined: Mon Mar 25, 2013 10:09 pm

Re: Add inventory slots line to example module. It crashes.

#2 Post by Castler »

What error messages are you getting in your te4_log.txt?
Qi Daozei (QDZ) - an Oriental-themed fantasy game for T-Engine. ToME Tips - auto-generated spoilers for ToME.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#3 Post by Psiweapon »

Had to erase previous log and reproduce it but here they are:

Code: Select all

[BIRTHER] Applying descriptor base
Lua Error: /engine/Birther.lua:421: attempt to call method 'initBody' (a nil value)
	At [C]:-1 initBody
	At /engine/Birther.lua:421 apply
	At /engine/Birther.lua:308 next
	At /engine/Birther.lua:135 fct
	At /engine/ui/ListColumns.lua:463 onUse
	At /engine/ui/ListColumns.lua:135 fct
	At /engine/Mouse.lua:58 receiveMouse
	At /engine/Mouse.lua:98 delegate
	At /engine/ui/Dialog.lua:657 mouseEvent
	At /engine/ui/Dialog.lua:399 fct
	At /engine/Mouse.lua:58 
The base descriptor I tried to implement:

Code: Select all

newBirthDescriptor{
	type = "base",
	name = "base",
	desc = {
	},
	experience = 1.0,
	--let's hope the following line doesn't crash everything
	--It did. Maybe multiple slots of the same name are guilty?
	--body = { INVEN = 12, MAINHAND=1, OFFHAND=1, UNDER=1, ARMOR=1, OVER=1, MISC=1 }
	body = { INVEN = 1000, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },

	copy = {
		max_level = 10,
		lite = 4,
		max_life = 25,
	},
}
My best guess now that I have found the error log is that I can't say "body" here without doing something else somewhere else, but I have no clues as to what. I'll try to look up something helpful on the reference but I'm not going to hold my breath... :(

Zireael
Archmage
Posts: 449
Joined: Tue Jun 18, 2013 7:24 pm

Re: Add inventory slots line to example module. It crashes.

#4 Post by Zireael »

Look in the te4 wiki. You need to require ActorInventory.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#5 Post by Psiweapon »

Damn, yes.

Even with a warning that it's NOT done in the example module. Reading stuff late at night, you miss and forget things.

Edit:
I did require ActorInventory and tried to define inventory slots in load.lua

Code: Select all

local ActorInventory = require "engine.interface.ActorInventory"
It still freezes with the same errors (attempt to call initBody with a nil value)

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Add inventory slots line to example module. It crashes.

#6 Post by HousePet »

Then stop calling initBody with a nil value. :P

What are you calling initBody with and are you sure every variable is defined?
My feedback meter decays into coding. Give me feedback and I make mods.

Castler
Thalore
Posts: 153
Joined: Mon Mar 25, 2013 10:09 pm

Re: Add inventory slots line to example module. It crashes.

#7 Post by Castler »

Are you sure you've read the error correctly and followed the wiki correctly?

Code: Select all

[BIRTHER] Applying descriptor base
Lua Error: /engine/Birther.lua:421: attempt to call method 'initBody' (a nil value)
This means that initBody is nil (i.e., you have no initBody method).
It still freezes with the same errors (attempt to call initBody with a nil value)
This means that a parameter to initBody is nil - that's a very different error.

If initBody itself is nil, and if all you've done is require ActorInventory:

Code: Select all

local ActorInventory = require "engine.interface.ActorInventory"
Then it sounds like you missed the step in the Objects Howto Guide of editing mod/class/Actor.lua and adding engine.interface.ActorInventory to its inheritances.
Qi Daozei (QDZ) - an Oriental-themed fantasy game for T-Engine. ToME Tips - auto-generated spoilers for ToME.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#8 Post by Psiweapon »

Castler wrote:Are you sure you've read the error correctly and followed the wiki correctly?

Code: Select all

[BIRTHER] Applying descriptor base
Lua Error: /engine/Birther.lua:421: attempt to call method 'initBody' (a nil value)
This means that initBody is nil (i.e., you have no initBody method).
It still freezes with the same errors (attempt to call initBody with a nil value)
This means that a parameter to initBody is nil - that's a very different error.

If initBody itself is nil, and if all you've done is require ActorInventory:

Code: Select all

local ActorInventory = require "engine.interface.ActorInventory"
Then it sounds like you missed the step in the Objects Howto Guide of editing mod/class/Actor.lua and adding engine.interface.ActorInventory to its inheritances.
It was the first kind of error, thanks for your reply, I kept following the wiki and got rid of that crash.

Sorry if I seem a bit stupid but I really only have a cursory understanding of programming.

Steven Aus
Archmage
Posts: 366
Joined: Sat Dec 13, 2014 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#9 Post by Steven Aus »

Don't worry, the worst you get with ToME4 programming is lua errors and the module or addon not loading. Most error messages you get give you a good idea what you need to fix. Trial and error, no-one is expecting you to be perfect. You get better as you go. :)

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#10 Post by Psiweapon »

Thanks, yeah, I'm starting to feel my way around those error reports.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Add inventory slots line to example module. It crashes.

#11 Post by Psiweapon »

Resolved, this thread can be closed.

Post Reply