onPickItem with sound help

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Eleven Warrior wrote:Hi again not sure what you mean

i'd add a modified onPickUpItem function to the cloneObject call.
Sorry Doc I truly wish I knew what you are talking about I really do, iam still so new at this sorry
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: onPickItem with sound help

Post by Dr.Disaster »

For each renamed item you need a cloneObject call.

Now while you can have a basic onPickUpItem in the defineObject call you can replace it with an individial onPickUpItem in each cloneObject call since cloneObject is used to override given defaults like you did with the item name.

Then if you cloned an object to let it have a specific name i don't think you'll need the "if" part in the function anymore because it would do something only with this specific clone.

Code: Select all

cloneObject{
   name="Book Of The Undead Volume 2",
   baseObject="book_undead_v2",
   ...
   onPickUpItem = function(champion, item)
      playSound("level_up")
   end
}
On the other hand you can extend your onPickUpItem function in the defineObject call to catch all possible item names with one line per name, similar to this

if ("item.name" == "book_undead_xx") then playsound("sound_xx") end,
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Eleven Warrior wrote:
Eleven Warrior wrote:Hi again not sure what you mean

i'd add a modified onPickUpItem function to the cloneObject call.
Sorry Doc I truly wish I knew what you are talking about I really do, iam still so new at this sorry
I must say the code looks good ahy but LOL I don't no how to use it, as it looks different to lua Scripts and what is Shell Script??

Ok this is The object: ------- This the new book Sorry -----
defineObject{
name = "the_king",
baseObject = "scroll",
uiName = "King Of Humans",
class = "Item",
model = "assets/models/items/tome.fbx",
gfxIndex = 30,
scroll = true,
weight = 0.3,
description = "This book was written by the famous Sage Orlandio and is the First Edition.",
}

This is the Clone Object:
cloneObject{
name = "The_King_Of_Humans_Volume_2",
uiName = "King Of Humans Volume 2",
baseObject = "the_king",
onPickUpItem = function (champion,item)
playSound("level_up")
description = "2nd Edition of The King.."
end
}

I hope I got this right I tried it and the sound does not play....
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: onPickItem with sound help

Post by Dr.Disaster »

move the description line above the onPickUpItem line, it does not belong there

Code: Select all

cloneObject{
   name = "The_King_Of_Humans_Volume_2",
   uiName = "King Of Humans Volume 2",
   baseObject = "the_king",
   description = "2nd Edition of The King..",
   onPickUpItem = function (champion,item)
      playSound("level_up")
   end,
}


shell script is the scripting language used on unix and linux systems
Last edited by Dr.Disaster on Wed Sep 18, 2013 12:42 am, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Eleven Warrior wrote:
Eleven Warrior wrote:
Eleven Warrior wrote:Hi again not sure what you mean

i'd add a modified onPickUpItem function to the cloneObject call.
Sorry Doc I truly wish I knew what you are talking about I really do, iam still so new at this sorry
I must say the code looks good ahy but LOL I don't no how to use it, as it looks different to lua Scripts and what is Shell Script??

Ok this is The object: ------- This the new book Sorry -----
defineObject{
name = "the_king",
baseObject = "scroll",
uiName = "King Of Humans",
class = "Item",
model = "assets/models/items/tome.fbx",
gfxIndex = 30,
scroll = true,
weight = 0.3,
description = "This book was written by the famous Sage Orlandio and is the First Edition.",
}

This is the Clone Object:
cloneObject{
name = "The_King_Of_Humans_Volume_2",
uiName = "King Of Humans Volume 2",
baseObject = "the_king",
onPickUpItem = function (champion,item)
playSound("level_up")
description = "2nd Edition of The King.."
end
}

I hope I got this right I tried it and the sound does not play....

Ok I have done this to my init.lua file: ---But I get the Error:: mod_assets/scripts/init.lua:111: unexpected symbol near ' , '

import "mod_assets/gui/initgui.lua"

cloneObject {
name = "party",
baseObject = "party",
onDrawGui = function(g)
return gui.onDrawGui(g)
end,
onMove = function(self, dir)
skyScript.onMove(dir)
if (gui.globalVars["shopOn"]) then
return false
else
return true
end
end,
onPickUpItem = function(champion, item)
if ( item.name == "book_undead_v2" )then playSound("mine_horror05") end, ----- Is this the problem, this is line 111 ----
if ( item.name == "the_king" )then playSound("mine_horror04") end

playSound("mine_horror10")
party:shakeCamera(1.5,2)
end
end
}
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: onPickItem with sound help

Post by Dr.Disaster »

Eleven Warrior wrote:Ok I have done this to my init.lua file: ---But I get the Error:: mod_assets/scripts/init.lua:111: unexpected symbol near ' , '
punctuation gets me too sometimes .. this should do

Code: Select all

cloneObject {
   name = "party",
   baseObject = "party",
   onDrawGui = function(g)
      return gui.onDrawGui(g)
   end,
   onMove = function(self, dir)
      skyScript.onMove(dir)
      if (gui.globalVars["shopOn"]) then
         return false
      else
         return true
      end
   end,
   onPickUpItem = function(champion, item)
        if ( item.name == "book_undead_v2" ) then playSound("mine_horror05") end
        if ( item.name == "the_king" ) then playSound("mine_horror04") end
        playSound("mine_horror10")     -- this sound will always play. intended?
        party:shakeCamera(1.5,2)
    end,
}
Last edited by Dr.Disaster on Wed Sep 18, 2013 12:52 am, edited 1 time in total.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Dr.Disaster wrote:move the description line above the onPickUpItem line, it does not belong there

Code: Select all

cloneObject{
   name = "The_King_Of_Humans_Volume_2",
   uiName = "King Of Humans Volume 2",
   baseObject = "the_king",
   description = "2nd Edition of The King..",
   onPickUpItem = function (champion,item)
      playSound("level_up")
   end,    ---- It does like the comma here so I took it out the book appears in Editor but still no sound sorry
}


shell script is the scripting language used on unix and linux systems
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Eleven Warrior wrote:
Dr.Disaster wrote:move the description line above the onPickUpItem line, it does not belong there

Code: Select all

cloneObject{
   name = "The_King_Of_Humans_Volume_2",
   uiName = "King Of Humans Volume 2",
   baseObject = "the_king",
   description = "2nd Edition of The King..",
   onPickUpItem = function (champion,item)
      playSound("level_up")
   end,    ---- It does like the comma here so I took it out the book appears in Editor but still no sound sorry
}


shell script is the scripting language used on unix and linux systems

Hey doc I realy appreciate you using your time on this, if there were more people like you in the world man the posabilities would be awesome..
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: onPickItem with sound help

Post by Dr.Disaster »

Are your custom sounds in the mod_assets/sounds directory and do they have the correct format (16bit 44100Hz .wav-files, preferably mono) ?
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: onPickItem with sound help

Post by Eleven Warrior »

Eleven Warrior wrote:
Eleven Warrior wrote:
Dr.Disaster wrote:move the description line above the onPickUpItem line, it does not belong there

Code: Select all

cloneObject{
   name = "The_King_Of_Humans_Volume_2",
   uiName = "King Of Humans Volume 2",
   baseObject = "the_king",
   description = "2nd Edition of The King..",
   onPickUpItem = function (champion,item)
      playSound("level_up")
   end,    ---- It does like the comma here so I took it out the book appears in Editor but still no sound sorry
}


shell script is the scripting language used on unix and linux systems

Hey doc I realy appreciate you using your time on this, if there were more people like you in the world man the posabilities would be awesome..
HEY DOC I GOT IT TO WORK IN MY INIT.LUA FILE CHECK THIS OUT::::

import "mod_assets/gui/initgui.lua"

cloneObject {
name = "party",
baseObject = "party",
onDrawGui = function(g)
return gui.onDrawGui(g)
end,
onMove = function(self, dir)
skyScript.onMove(dir)
if (gui.globalVars["shopOn"]) then
return false
else
return true
end
end,
onPickUpItem = function(champion, item)
if ( item.name == "book_undead_v2" )then playSound("mine_horror05") end ----- Is this the problem, this is line 111 ----
if ( item.name == "the_king" )then playSound("mine_horror04")

--if ( item.name == "book_undead_v2" ) or (item.name == "the_king") then ----- I FORGOT TO TAKE THESE LINES OUT SORRY ABOUT THAT
--playSound("mine_horror10")
--party:shakeCamera(1.5,2)
end
end
}
Post Reply