Add inventory slots line to example module. It crashes.
Moderator: Moderator
Add inventory slots line to example module. It crashes.
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.
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.
Re: Add inventory slots line to example module. It crashes.
Had to erase previous log and reproduce it but here they are:
The base descriptor I tried to implement:
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... 
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
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,
},
}

Re: Add inventory slots line to example module. It crashes.
Look in the te4 wiki. You need to require ActorInventory.
Re: Add inventory slots line to example module. It crashes.
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
It still freezes with the same errors (attempt to call initBody with a nil value)
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"
Re: Add inventory slots line to example module. It crashes.
Then stop calling initBody with a nil value.
What are you calling initBody with and are you sure every variable is defined?

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.
Re: Add inventory slots line to example module. It crashes.
Are you sure you've read the error correctly and followed the wiki correctly?
If initBody itself is nil, and if all you've done is require 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.
This means that initBody is nil (i.e., you have no initBody method).Code: Select all
[BIRTHER] Applying descriptor base Lua Error: /engine/Birther.lua:421: attempt to call method 'initBody' (a nil value)
This means that a parameter to initBody is nil - that's a very different error.It still freezes with the same errors (attempt to call initBody with a nil value)
If initBody itself is nil, and if all you've done is require ActorInventory:
Code: Select all
local ActorInventory = require "engine.interface.ActorInventory"
Re: Add inventory slots line to example module. It crashes.
It was the first kind of error, thanks for your reply, I kept following the wiki and got rid of that crash.Castler wrote:Are you sure you've read the error correctly and followed the wiki correctly?
This means that initBody is nil (i.e., you have no initBody method).Code: Select all
[BIRTHER] Applying descriptor base Lua Error: /engine/Birther.lua:421: attempt to call method 'initBody' (a nil value)
This means that a parameter to initBody is nil - that's a very different error.It still freezes with the same errors (attempt to call initBody with a nil value)
If initBody itself is nil, and if all you've done is require 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.Code: Select all
local ActorInventory = require "engine.interface.ActorInventory"
Sorry if I seem a bit stupid but I really only have a cursory understanding of programming.
-
- Archmage
- Posts: 366
- Joined: Sat Dec 13, 2014 3:38 pm
Re: Add inventory slots line to example module. It crashes.
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. 

Re: Add inventory slots line to example module. It crashes.
Thanks, yeah, I'm starting to feel my way around those error reports.
Re: Add inventory slots line to example module. It crashes.
Resolved, this thread can be closed.