Page 2 of 2

Re: Spawning Sack sand boxes with loot in them

Posted: Mon Nov 17, 2014 1:13 am
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 ?

Re: Spawning Sack sand boxes with loot in them

Posted: Sun Jul 23, 2017 11:14 am
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

Re: Spawning Sack sand boxes with loot in them

Posted: Sun Jul 23, 2017 1:30 pm
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