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

Spawning Sack sand boxes with loot in them

Post by KhellQc »

I would like to spawn a Sack with specific loot inside it upon digging it.

Right now I am using this
Floor_trigger upon digging > Spawner Dig_hole
> Spawner Sack but I want stuff to be in it.

Can you please help ?
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: Spawning Sack sand boxes with loot in them

Post by maneus »

Use the following code in a script for spawn items inside the sack (original script by JohnWordsworth).
Change the coordinates and the items you want to spawn inside for yourself.

Code: Select all

function createSackWithItems()

  local container = spawn("sack", 5, 12, 5, 0)
  local sword = spawn("long_sword")
  local knives = spawn("throwing_knife")
  knives:setStackSize(3)
  container:addItem(knives)
  container:addItem(sword)
end
Activate the script by lever or timer. This should work for you.
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 »

maneus wrote:Use the following code in a script for spawn items inside the sack (original script by JohnWordsworth).
Change the coordinates and the items you want to spawn inside for yourself.

Code: Select all

function createSackWithItems()

  local container = spawn("sack", 5, 12, 5, 0)
  local sword = spawn("long_sword")
  local knives = spawn("throwing_knife")
  knives:setStackSize(3)
  container:addItem(knives)
  container:addItem(sword)
end
Activate the script by lever or timer. This should work for you.
Sweet, where did you get it?

= spawn("sack", 5, 12, 5, 0) is this, x, y, z, ? of the level I am currently working on ?) whats the forth?)


And this would be a little trickier. I want to spawn a Textscroll with text in it obivously IN THE SACK. I know i could simply have the scrolls spawn next to the sack but I like details, so is it possible and how ?

Thank again
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 »

jjust found that

Skuggasveinn

spawn("torch", 8, 15, 16, 1, 0,"DazUberTorch")
spawn("asset", X, Y, Facing, Elevation, "name")

first is the asset you wan't to spawn
8 is the level, in the order that they are listed in your dungeon editor, the top most level being 1 and then going 2,3,4 as they descend down (don't mix this up with coordinates the tell the game how your levels and the minimap interact)
15 is the X
16 is the Y
1 is the facing (from 0 to 3 )
0 is the elevation
and then comes the name (and that's optional if you never need to call this again.)
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 »

maneus wrote:Use the following code in a script for spawn items inside the sack (original script by JohnWordsworth).
Change the coordinates and the items you want to spawn inside for yourself.

Code: Select all

function createSackWithItems()

  local container = spawn("sack", 5, 12, 5, 0)
  local sword = spawn("long_sword")
  local knives = spawn("throwing_knife")
  knives:setStackSize(3)
  container:addItem(knives)
  container:addItem(sword)
end
Activate the script by lever or timer. This should work for you.




knives:setStackSize(3) ----> Attemp to call metod setStackSize ( a nil value)


I tried to remove the stacks, but then

container:addItem(knives) ---> same thing attemps to call addItem ( nil value)
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: Spawning Sack sand boxes with loot in them

Post by maneus »

Can you give me your script you did in the editor? Maybe I found the mistake.

For adding a scroll with text into the sack do:

Code: Select all

local message = spawn("note")
message:setScrollText("Your text here.")
container:addItem(message)
If you get an error for the stacksize maybe you have not a item that is stackable in your changed script.

I´ve tested the script I gave you by myself and it works fine.

For spawning a item into a container there is no need to give the item coordinates(level, x, y, facing). The name is all you need.
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 »

maneus wrote:Can you give me your script you did in the editor? Maybe I found the mistake.

For adding a scroll with text into the sack do:

Code: Select all

local message = spawn("note")
message:setScrollText("Your text here.")
container:addItem(message)
If you get an error for the stacksize maybe you have not a item that is stackable in your changed script.

I´ve tested the script I gave you by myself and it works fine.

For spawning a item into a container there is no need to give the item coordinates(level, x, y, facing). The name is all you need.
This is what is my Lua
function createSackWithItems()

local container = spawn("sack", 1, 12, 15, 1, 0)
local sword = spawn("long_sword")
local knives = spawn("throwing_knife")
container:addItem(knives)
container:addItem(sword)
end

mmh, I just copy paste the script you gave to first test it, its not changed. only the coordinate of the sack spawn. I did it it to know how to do stacks in the future but i dont need it for now. Maybe this would help to know that this is triggered by digging a hole ?
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 »

function createSackWithItems()

local message = spawn("scroll")
message:setScrollText("Send the Northern Star a bla bla bla")
local staff = spawn("shaman_staff")
local container = spawn("wooden_box", 1, 12, 15, 1, 0)
container:addItem(message)
container:addItem(staff)
end


Thats what I am working with right now, and it says attempt to call method setScrolltext ( a nil value)
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: Spawning Sack sand boxes with loot in them

Post by maneus »

Please delete the red things and try it again:

function createSackWithItems()

local message = spawn("scroll")
message:setScrollText("Send the Northern Star a bla bla bla")
local staff = spawn("shaman_staff")
local container = spawn("wooden_box", 1, 12, 15, 1, 0)
container:addItem(message)
container:addItem(staff)
end


You only need to define the level, the x-, the y-coordinates and the object facing.
I think Skuggasveinn´s entry was for LoG2.

If you will spawn the wooden box inside Legend of Grimrock 2 then you ask in the wrong section of the forum.
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 »

done, still seem to refuse the method message:setScrollText("blabla...


these guys been trying to do it too but I dont see the solution in those posts...

viewtopic.php?f=22&t=7306&p=75102&hilit ... ext#p75102
Post Reply