Treasure Chest problems

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Treasure Chest problems

Post by solomonsgrave »

Hello I gots me a problem.I downloaded the treasure chests by Xanathar.I follow the readme and copy the script exactly,no changes.Then I place a treasure chest with all the other bits that are required.When I open the chest,it opens fine,but when I click on it to get the items then the preview
crashes.I get this error message------->attempt to get length of field "items"(a nil value)------------ on this line of script
-------->elseif (context.chestState >= 1 and context.chestState <= #script.items) then------------ in the chest manager. Im new to this stuff
so to me that error message has(a nil value),I have no clue what it means.Any help will be greatly welcome.......Thanks
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: Treasure Chest problems

Post by Dr.Disaster »

My guess would be that you made a mistake editing the "items" line of the chest definition. Yet it would help to post what you scripted.
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Re: Treasure Chest problems

Post by solomonsgrave »

-- Put the list of items contained in the chest, see also "onItemSpawn"
items = { "torch", "pitroot_bread", "tar_bead" }
-- Put the name of the opening item for locked chests, or nil for unlocked chests
lock_key = nil
-- Put name of monster to spawn inside chest; should be a kind-of tentacle type monster
mimicry = nil
-- Put the name of the trap item to fire on opening, or nil for no trap
trap_item = nil
-- Put the message for empty chest here, or nil for no message
msg_empty = "The chest is empty"
-- Put the message for locked chest here, or nil for no message
msg_locked = "The chest is locked"
-- Put the sound to be played when the chest is opened or closed, or nil for no sound
sound = "wav_chest"
-- Set this to true to have it stay open after finished getting items
stay_open = true
-- Set this to a number to have the chest be breakable
hitpoints = nil
-- Set this to the random chance of breaking an item (percentage) after breaking the chest
breakchance = nil
-- Set the message to print if an item breaks
msg_break = "Whatever it was, it crumbled to dust"

-- here you can filter the created items, should return the item to give
-- use this to customize returned items (set scroll text, stack size, etc.)
function onItemSpawn(index, item)
return item
end

-- here you can act on chest opening, if returns false, the chest won't open
-- note: if it returns false for locked chests, the key is wasted
-- traps and keys are already managed natively
function onChestOpen(chest)
return true
end
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Re: Treasure Chest problems

Post by solomonsgrave »

That is the chest template I changed nothing just copy/paste it I figured the items already listed would be the default.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Treasure Chest problems

Post by msyblade »

I see a few conflicts, although im not sure if they are causing the crash:

Change "msg_empty" , "msg_locked" and "msg_break" to nil (no quotes). It is choosing to display all 3 messages even tho the field to lock the chest is set to nil, the breakchance is 0, and items are present. Xanathar is busy at work for the next week or so, but if you are patient and move on with your mod, he will be happy to help you get it working when he returns, i'm sure.

Hope this helps!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: Treasure Chest problems

Post by Dr.Disaster »

solomonsgrave wrote:That is the chest template I changed nothing just copy/paste it I figured the items already listed would be the default.
Well if you did not change anything then you did not follow the instructions exactly given in the chest README.

I'm no modder but the chest works flawless for me. All i did was download the chest from nexus and followed the README instructions to add it unmodified to the Chakram demo dungeon which i've been toying with lately and voila! i got a working treasure chest.
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Re: Treasure Chest problems

Post by solomonsgrave »

Instructions:

== FIRST TIME SETUP ==
1) follow the license procedure below - give credit where credit is due!
2) copy the folder "chest" under your dungeon mod_assets directory
3) add the following to your init.lua file: import "mod_assets/chest/chest.lua"
4) open the file "chestmanager.txt" and copy its contents into a scripting entity called "chestmanager" anywhere in your dungeon


== TO CREATE A TREASURE CHEST ==
1) Create a "treasure_chest" object anywhere in the dungeon.
2) Paste the content of "chest_template.txt" file there, then edit the parts you want as explained in that text.
3) Place a floor (like dungeon_floor_drainage or similar) below the chest!

== TO CREATE A TREASURE CHEST DYNAMICALLY ==
If you want to create a treasure chest at runtime execute a script similar to this:

function spawnchest()
chestmanager.addchest {
id = "somerandomwhatever",
name = "treasure_chest_dark",
level = 1,
x = 19,
y = 21,
facing = 0,
items = { "torch", "pitroot_bread", "tar_bead" },
msg_empty = "The chest is empty",
msg_locked = "The chest is locked",
sound = "wav_chest",
stay_open = true,
msg_break = "Whatever it was, it crumbled to dust",
}
end

All the rows from id to items are mandatory, other rows are optional. Every function and variable which can be specified in
static treasure chests can also be used in dynamic ones.

WARNING: Remember to create a chest only in places where you previously placed a floor prop!!



== LICENSING ==
You can put or omit credits to me, if you do I appreciate (oh the ego :)), but I'm not enforcing you to do so.
You *must* however put the following text in the dungeon description to credit the author of the treasure chest model who was very kind to provide a great 3d model for free.

The 3D Model of the treasure chest is copyright of Robin Wood (http://www.robinwood.com), used with permission from the author.

The darker texture of the treasure chest is a work by Germanny.
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Re: Treasure Chest problems

Post by solomonsgrave »

That is the readme that came with the chests mod.
FIRST TIME SETUP
I got step 1-4 done.
Licensing in the desciption,check.
Copy chest folder to mod_assets,check.
Copy/paste the import line to my init.lua,check.
Create script entity named chestmanager,and copy/paste the chestmanager.txt contents to it,check.
TO CREATE A TREASURE CHEST
This is where Im confused,Im not sure if by---
1) Create a "treasure_chest" object anywhere in the dungeon.
If he means to create a script entity named treasure_chest,cuz that is what I did
Then I put the "chest_template.txt contents in that script entity.
Then I placed a floor and put a chest there.
and thats where were at.Im not sure what Im missing unless its the step I mentioned.
solomonsgrave
Posts: 12
Joined: Sun Aug 18, 2013 10:43 pm

Re: Treasure Chest problems

Post by solomonsgrave »

HAHAHA IM AN IDIOT.LOL I didnt see there was a spot for script on the actual treasure chest.
I assumed he meant a script entity.I got it now,and that is why Im a blacksmith not a programmer.
Thanks everyone!!!!
Post Reply