Page 1 of 1
Add inventory slots line to example module. It crashes.
Posted: Sat Mar 19, 2016 3:48 pm
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.
Re: Add inventory slots line to example module. It crashes.
Posted: Sun Mar 20, 2016 3:08 am
by Castler
What error messages are you getting in your te4_log.txt?
Re: Add inventory slots line to example module. It crashes.
Posted: Sun Mar 20, 2016 3:42 am
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...

Re: Add inventory slots line to example module. It crashes.
Posted: Sun Mar 20, 2016 11:28 am
by Zireael
Look in the te4 wiki. You need to require ActorInventory.
Re: Add inventory slots line to example module. It crashes.
Posted: Sun Mar 20, 2016 3:10 pm
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)
Re: Add inventory slots line to example module. It crashes.
Posted: Mon Mar 21, 2016 12:41 am
by HousePet
Then stop calling initBody with a nil value.
What are you calling initBody with and are you sure every variable is defined?
Re: Add inventory slots line to example module. It crashes.
Posted: Mon Mar 21, 2016 1:26 am
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.
Re: Add inventory slots line to example module. It crashes.
Posted: Tue Mar 22, 2016 6:55 pm
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.
Re: Add inventory slots line to example module. It crashes.
Posted: Wed Mar 23, 2016 3:03 pm
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.

Re: Add inventory slots line to example module. It crashes.
Posted: Wed Mar 23, 2016 3:28 pm
by Psiweapon
Thanks, yeah, I'm starting to feel my way around those error reports.
Re: Add inventory slots line to example module. It crashes.
Posted: Sun Mar 27, 2016 12:00 am
by Psiweapon
Resolved, this thread can be closed.