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
melierax
Posts: 29
Joined: Sat Oct 27, 2012 2:08 am
Location: Quebec, Canada

Re: Ask a simple question, get a simple answer

Post by melierax »

Code: Select all

defineObject {
       name = "exploding_barrel_block",
       baseObject = "barrel_crate_block",
       components = {
          {
             class = "Health",
             health = 30,
             onDie = function(c)
                if ( c.property ~= nil ) then
                   --print("BLOCKED")
                   return
                end
                
                c.property = 1;
                local i, j;
                
                for i = -1, 1 do
                   for j = -1, 1 do
                      spawn("fireburst", c.go.level, c.go.x + i, c.go.y + j, 0, c.go.elevation)
                   end
                end
             end
          }
       }
    }

 defineObject {
       name = "nour_barrel_block",
       baseObject = "barrel_crate_block",
       components = {
          {
             class = "Health",
             health = 15,
             onDie = function(c)
                if ( c.property ~= nil ) then
                   --print("BLOCKED")
                   return
                end
                
                c.property = 1;
                      spawn("nour_barrel_crate_block_damaged", c.go.level, c.go.x, c.go.y, 0, c.go.elevation)
             end
          }
       }
    }


defineObject {
       name = "nour_barrel_crate_block_damaged",
       baseObject = "barrel_crate_block_damaged",
       components = {
          {
             class = "Health",
             health = 15,
              onDie = function(self)
    local foodList = {"ice_lizard_steak", "baked_maggot", "boiled_beetle", "rat_shank", "pitroot_bread", "herder_cap"}
    local many = math.random(1, 4)
    local facing = (party.facing + 2)%4

    for i = 1, many do
    spawn(foodList[math.random(1, #foodList)], self.go.level, self.go.x, self.go.y, math.random(0, 3), self.go.elevation)

    end
       end
          }
       }
    }

User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

melierax wrote: Wed Oct 02, 2019 10:10 pm

Code: Select all

defineObject {
       name = "exploding_barrel_block",
       baseObject = "barrel_crate_block",
       components = {
          {
             class = "Health",
             health = 30,
             onDie = function(c)
                if ( c.property ~= nil ) then
                   --print("BLOCKED")
                   return
                end
                
                c.property = 1;
                local i, j;
                
                for i = -1, 1 do
                   for j = -1, 1 do
                      spawn("fireburst", c.go.level, c.go.x + i, c.go.y + j, 0, c.go.elevation)
                   end
                end
             end
          }
       }
    }

 defineObject {
       name = "nour_barrel_block",
       baseObject = "barrel_crate_block",
       components = {
          {
             class = "Health",
             health = 15,
             onDie = function(c)
                if ( c.property ~= nil ) then
                   --print("BLOCKED")
                   return
                end
                
                c.property = 1;
                      spawn("nour_barrel_crate_block_damaged", c.go.level, c.go.x, c.go.y, 0, c.go.elevation)
             end
          }
       }
    }


defineObject {
       name = "nour_barrel_crate_block_damaged",
       baseObject = "barrel_crate_block_damaged",
       components = {
          {
             class = "Health",
             health = 15,
              onDie = function(self)
    local foodList = {"ice_lizard_steak", "baked_maggot", "boiled_beetle", "rat_shank", "pitroot_bread", "herder_cap"}
    local many = math.random(1, 4)
    local facing = (party.facing + 2)%4

    for i = 1, many do
    spawn(foodList[math.random(1, #foodList)], self.go.level, self.go.x, self.go.y, math.random(0, 3), self.go.elevation)

    end
       end
          }
       }
    }

Thank you :)
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

How do I add a walking sound in this Tile below. The floor is wood and i have a sound that sounds like the party is walking on a wood floor but i dont know how to add the code into the tile code ty :)

Code: Select all

defineTile{
  name = "sx_ship_arena",
  editorIcon = 112,
  color = {120,120,45,125},
  randomFloorFacing = false,
  solid = false,
  builder = "dungeon",
	floor = {
	"sx_ship_floor", 1,
	},
	automapTile = "ground",
}
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

you add moveSound ="my_sound", in the definition

Code: Select all

defineTile{
  name = "sx_ship_arena",
  editorIcon = 112,
  color = {120,120,45,125},
  randomFloorFacing = false,
  solid = false,
  builder = "dungeon",
	floor = {
	"sx_ship_floor", 1,
	},
	automapTile = "ground",
	moveSound = "my_sound",
}
then you have to define your moveSound.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

How do I add a stack of 4 rocks to the Mouse Pointer ty :)

EDIT: Dump sorry.
Last edited by Eleven Warrior on Fri Oct 04, 2019 8:29 pm, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

How do I get this script to check the ID of the item eg: rock_1 not just the UI name rock?

Code: Select all

-- Check if party is carrying item the door opens --
function dooropen01()
if party.party:isCarrying("rock") then
	dungeon_door_iron_1.door:open()
		hudPrint("You have the rock to open the door.")
else
	dungeon_door_iron_1.door:close()
		hudPrint("You need a rock to open this door friends.")
 end
end
User avatar
7Soul
Posts: 212
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Eleven Warrior wrote: Fri Oct 04, 2019 5:35 am How do I get this script to check the ID of the item eg: rock_1 not just the UI name rock?
Try this

Code: Select all

local rock = false
for c=1,4 do
	local champion = party.party:getChampionByOrdinal(c)
	for slot=1,ItemSlot.MaxSlots do
		local item = champion:getItem(slot)
		if item and item.go.id == "rock_1" then
			rock = true
			break
		end
	end
end
if rock then
	-- has rock_1
else
	-- doesn't have it
end
Join the LoG discord server: https://discord.gg/S6pYmuAwWm :D

My Mods
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Thank you kindly for the Script mate :)

EDIT: It needs to be a function. A floor_trigger activates the script checks for the item then stuff happens sorry.
User avatar
7Soul
Posts: 212
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Eleven Warrior wrote: Fri Oct 04, 2019 8:17 pm Thank you kindly for the Script mate :)

EDIT: It needs to be a function. A floor_trigger activates the script checks for the item then stuff happens sorry.
Put it in a function then
Join the LoG discord server: https://discord.gg/S6pYmuAwWm :D

My Mods
User avatar
Zo Kath Ra
Posts: 940
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

7Soul wrote: Sat Oct 05, 2019 12:29 am
Eleven Warrior wrote: Fri Oct 04, 2019 8:17 pm Thank you kindly for the Script mate :)

EDIT: It needs to be a function. A floor_trigger activates the script checks for the item then stuff happens sorry.
Put it in a function then
Genius :)
Post Reply