onPickUpItem - Static item (original item vs mod item)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Damonya
Posts: 134
Joined: Thu Feb 28, 2013 1:16 pm
Location: France
Contact:

onPickUpItem - Static item (original item vs mod item)

Post by Damonya »

I try to make a game item to static. Impossible to pick up.

It works very well with an item of original games. But if I try to create my own item, it does not work anymore. I don't know why.

Example with the original skull :

items.lua
SpoilerShow

Code: Select all

defineObject{
		name = "skull_fake",
		class = "Item",
		uiName = "Skull",
		model = "assets/models/items/skull.fbx",
		gfxIndex = 31,
		weight = 1.0,
	}	
init.lua
SpoilerShow

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",
   onPickUpItem = function(party, item) -- called when any item is picked up
      if item.name == "skull_fake" then
         return false -- cancel the pickup action

	  end
   end,
}	
skull_fake is static. It's OK.

But when I want to take an item from a mod. It does not work. Example with the skull pack of Asteroth6

items.lua
SpoilerShow

Code: Select all

defineObject{
		name = "skull_stone_fake",
		class = "Item",
                gfxAtlas = "mod_assets/textures/icons/items_s.tga",
		uiName = "Stone Skull",
		model = "mod_assets/models/stone_skull.fbx",
		gfxIndex = 29,
		weight = 1.0,
	}	
init.lua
SpoilerShow

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",
   onPickUpItem = function(party, item) -- called when any item is picked up
      if item.name == "skull_stone_fake" then
         return false -- cancel the pickup action

	  end
   end,
}	
The skull_stone_fake is still picked up. I'm close but I don't understand why.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: onPickUpItem - Static item (original item vs mod item)

Post by Komag »

is that a second cloned party? only have one, just add another line within the onPickUpItem hook
Finished Dungeons - complete mods to play
User avatar
Damonya
Posts: 134
Joined: Thu Feb 28, 2013 1:16 pm
Location: France
Contact:

Re: onPickUpItem - Static item (original item vs mod item)

Post by Damonya »

Komag wrote:is that a second cloned party? only have one, just add another line within the onPickUpItem hook
Ok thanks. Really a newbie error. It works great now of course.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: onPickUpItem - Static item (original item vs mod item)

Post by Komag »

No problem :)
Finished Dungeons - complete mods to play
Post Reply