Spawning Sack sand boxes with loot in them

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
KhellQc
Posts: 25
Joined: Sat Nov 15, 2014 11:15 pm

Re: Spawning Sack sand boxes with loot in them

Post by KhellQc »

Hey I just tried that from Lark

message.scrollitem:setScrollText("This is an important\nmessage!")


I removed the container:additem for message and staff and they all spawn next the to the wooden box.

attempt to call the method additem ( a nil value)

Adding it to that box if the issues. Should we name (id) the box ?
TBWNight
Posts: 1
Joined: Sun Jul 23, 2017 11:09 am

Re: Spawning Sack sand boxes with loot in them

Post by TBWNight »

function sackWithLongSword()
self.go:spawn("sack").containeritem:addItem(spawn("long_sword").item)
end

In LOG2 you would have to do this to make a sack with an item, in this case a long sword

You could also do this

function sackWithLongSword()
local sack = spawn("sack", 1, 15, 15, 0)
sack.containeritem:addItem(spawn("long_sword").item)
end

This is because components are different from strings
I would recommend steering clear of coding in LOG2 for anyone not used to lua
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Spawning Sack sand boxes with loot in them

Post by Isaac »

TBWNight wrote:function sackWithLongSword()
self.go:spawn("sack").containeritem:addItem(spawn("long_sword").item)
end
Welcome to the forum TBWNight. 8-)

This is the LoG(1) section of the forum, so the Lua script examples have to take into account the lack of a component model in LoG1.

*Meaning: self.go:spawn("sack").containeritem:addItem(spawn("long_sword").item) does not work in LoG1.

(Because there are no .go and no .containerItem, and no .item in the game objects.)

**Also, this thread is three years old. :o
Post Reply