Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
TSotP
Posts: 74
Joined: Tue Oct 15, 2013 8:42 am

Re: Ask a simple question, get a simple answer

Post by TSotP »

do chests count as a surface? i'm trying to modify Skuggasveinn alcove script to have a chest open a door when a specific item is inserted.

one of the problems is that the specific item is one that i spawned using this code

Code: Select all

local twig = self.go:spawn("branch")
twig.item:setDescription("A small twig from a tree")
twig.item:setWeight(0.8)
twig.item:setUiName("Twig")
i'm then using this for my chest

Code: Select all

function surfaceContains(surface, item)
   for v,i in surface:contents() do
   if i.go.name == item then return true
   end
end
end

function openShieldDoor()
   if surfaceContains(twig_chest.surface, "twig") then
   tomb_door_portcullis_4.door:open()
   else
   tomb_door_portcullis_4.door:close()
   end
end
but nothing happens when i put the 'twig' in the chest. I have the chest connected to the 'openShieldDoor' function. I have no idea what i am doing wrong.

Once i get this working, i just need to copy it 3 times for the other 3 doors&items and i'm about half way through completing my knightmare re-remake lol
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

I think you will need to define the new item. look at Skuggasveinn's tutorial 12 on making a new/cloned item. I tested your code and if you change twig to branch:
if surfaceContains(dungeon_alcove_1.surface, "branch") then
the door will open with a branch or your spawned twig.
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Ask a simple question, get a simple answer

Post by cameronC »

I get an "invalid spell gesture" error when trying to load a dungeon with one custom spell defined. The gesture line reads:

Code: Select all

gesture = 16,
The scripting ref says it just takes a numeric value of the runes. What am I doing wrong? I've changed the rune numbers multiple times without anything changing.
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Ask a simple question, get a simple answer

Post by petri »

The gesture 16 is invalid because you can't draw that on the rune panel. It must be a continuous line.
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Ask a simple question, get a simple answer

Post by cameronC »

petri wrote:The gesture 16 is invalid because you can't draw that on the rune panel. It must be a continuous line.
Doh! Thank you!
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
User avatar
blob
Posts: 50
Joined: Fri Aug 02, 2013 9:34 am

Re: Ask a simple question, get a simple answer

Post by blob »

NutJob wrote: If you only want to change some fundamentals of an object just spawn it in and change what you want.

Example

Code: Select all

local skull_of_dargoth = spawn("skull")
skull_of_dargoth.item:setDescription("Only in purest darkness\nshall the way be shown.")
skull_of_dargoth.item:setWeight(0.8)
skull_of_dargoth.item:setUiName("Brittle Human Skull")
I'm trying to do that but with spawning a beacon head and swapping the model but I can't get it to work.

Code: Select all

local beacon_furnace_head = spawn("beacon_furnace_head")
beacon_furnace_head.object:setModel(assets/models/env/demon_head.model)
I'm way off aren't I? : l
User avatar
Matlock19
Posts: 23
Joined: Sun Nov 02, 2014 2:11 am

Re: Ask a simple question, get a simple answer

Post by Matlock19 »

edit: moved everything to another post.
Last edited by Matlock19 on Fri Nov 07, 2014 9:58 am, edited 2 times in total.
User avatar
TSotP
Posts: 74
Joined: Tue Oct 15, 2013 8:42 am

Re: Ask a simple question, get a simple answer

Post by TSotP »

blob wrote:
NutJob wrote: If you only want to change some fundamentals of an object just spawn it in and change what you want.

Example

Code: Select all

local skull_of_dargoth = spawn("skull")
skull_of_dargoth.item:setDescription("Only in purest darkness\nshall the way be shown.")
skull_of_dargoth.item:setWeight(0.8)
skull_of_dargoth.item:setUiName("Brittle Human Skull")
I'm trying to do that but with spawning a beacon head and swapping the model but I can't get it to work.

Code: Select all

local beacon_furnace_head = spawn("beacon_furnace_head")
beacon_furnace_head.object:setModel(assets/models/env/demon_head.model)
I'm way off aren't I? : l
is that second code the exact code you are using? I might be way off, but isn't the demon head spelled "daemon_head.model"?
User avatar
blob
Posts: 50
Joined: Fri Aug 02, 2013 9:34 am

Re: Ask a simple question, get a simple answer

Post by blob »

The model name I found in the .dat file was demon_head.model but yeah its named daemon_head in LoG's editor. I tried both.
Maybe its the way I write the path that is wrong?
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Ask a simple question, get a simple answer

Post by JohnWordsworth »

You will definitely want to make sure you are passing a string to setModel by adding quotes around the path...

Code: Select all

beacon_furnace_head.object:setModel("assets/models/env/demon_head.model")
But you might also need to refer to the model with an FBX extension (if the code runs like model defines) like so...

Code: Select all

beacon_furnace_head.object:setModel("assets/models/env/demon_head.fbx")
I'm not able to test either of those at the moment, but it might give you somewhere to look next.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Post Reply