Changing item descriptions on equip

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Gradunk
Posts: 54
Joined: Tue Oct 22, 2013 2:26 am
Location: Calgary, Canada

Changing item descriptions on equip

Post by Gradunk »

how? that's all i really need to say.
onEquipItem = function(champion,slot)
description = "It seems to have glued itself to your body. You have no knowledge of how to remove it. You then feel a dark connection to the shield and a surge of power flows through you. You never want to take it off anyway."
end

that for some reason wont even let me run the game.

onUnequipItem = function(champion,slot)
if slot == 8 then
equipStopper.stopUnequip(champion,slot)
end
end

but that will. i'm trying to make it so you can't remove the item and the description to change to reflect that. but neither are working properly.
any help on this one?
I smell you, i do! You GRADUNK! No be hiding on TORGAL!
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: Changing item descriptions on equip

Post by Leki »

Make two items, if first is equiped, get slot and replace it with the second one with that new description, in UnEqupi handler work with 2nd item. I guess you can define onUnequip hook in that 2nd item to return false and you no need that stoppers.
P.S: Use "Code" tags if you post codes.
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Changing item descriptions on equip

Post by Isaac »

Additionally... Your onEquipItem hook is a function without a closing End. That would stop the game, unless you've abridged the code here.
Gradunk
Posts: 54
Joined: Tue Oct 22, 2013 2:26 am
Location: Calgary, Canada

Re: Changing item descriptions on equip

Post by Gradunk »

Isaac wrote:Additionally... Your onEquipItem hook is a function without a closing End. That would stop the game, unless you've abridged the code here.
not quite sure what you mean by that. I've found out a way to change the description but that entails a pressure plate and the item having been previously equipped.
I haven't once been able to get any onEquipItem OR on onUnequipItem hook to actually execute. they will compile and the game will run but they do nothing.
can you paste an onEquipItem hook that you've used and say how you got it to run? cause i'm at a loss here... again.
I smell you, i do! You GRADUNK! No be hiding on TORGAL!
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Changing item descriptions on equip

Post by Isaac »

Gradunk wrote:
Isaac wrote:Additionally... Your onEquipItem hook is a function without a closing End. That would stop the game, unless you've abridged the code here.
not quite sure what you mean by that. I've found out a way to change the description but that entails a pressure plate and the item having been previously equipped.
I haven't once been able to get any onEquipItem OR on onUnequipItem hook to actually execute. they will compile and the game will run but they do nothing.
can you paste an onEquipItem hook that you've used and say how you got it to run? cause i'm at a loss here... again.
Example: (This adds a 'Dagger Hook Example' item; place and equip with any character.)

Code: Select all

defineObject{
		name = "dagger_hook",
		class = "Item",
		uiName = "Dagger Hook Example",
		model = "assets/models/items/dagger.fbx",
		skill = "daggers",
		gfxIndex = 10,
		attackPower = 7,
		accuracy = 5,
		coolDownTime = 2.5,
		attackMethod = "meleeAttack",
		attackSwipe = "vertical",
		attackSound = "swipe_light",
		impactSound = "impact_blade",
		weight = 0.8,

		onEquipItem = function(champion, slot)

							local pronoun = {["male"]="his",["female"]="her"} -- Gender word
							local hand = {["7"]="left", ["8"]="right"}		  -- left/right hand word
							hudPrint(" ") hudPrint(" ") hudPrint(" ") hudPrint(" ")			  -- clear the previous texts

							hudPrint(champion:getName().." holds the dagger ")
							hudPrint("in "..pronoun[champion:getSex()].." "..hand[tostring(slot)].." hand.")
						end,

		onUnequipItem = function(champion, slot)
							hudPrint(" ") hudPrint(" ") hudPrint(" ") hudPrint(" ")			  -- clear the previous texts

							hudPrint(champion:getName().." puts the dagger away.")
						end,

	}
Gradunk
Posts: 54
Joined: Tue Oct 22, 2013 2:26 am
Location: Calgary, Canada

Re: Changing item descriptions on equip

Post by Gradunk »

Thanks. now i got it working. i wasn't putting it in the right place. now my question is.
How do i insertItem() on one of those onEquipItem or onUnequipItem commands?

Code: Select all

onEquipItem = function(champion, slot)
	if slot == 7 or slot == 8 then
		champion:removeItem(slot)
      champion:insertItem(doesn't, matter)
	end	
end
the obvious line crashes the game regardless of what i try to insert.
I smell you, i do! You GRADUNK! No be hiding on TORGAL!
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Changing item descriptions on equip

Post by Isaac »

Gradunk wrote:...
'Item' cannot be by name, it must be spawned. (There are two ways shown in the updated code.)

Code: Select all

	defineObject{
		name = "dagger_hook",
		class = "Item",
		uiName = "Dagger Hook Example",
		model = "assets/models/items/dagger.fbx",
		skill = "daggers",
		gfxIndex = 10,
		attackPower = 7,
		accuracy = 5,
		coolDownTime = 2.5,
		attackMethod = "meleeAttack",
		attackSwipe = "vertical",
		attackSound = "swipe_light",
		impactSound = "impact_blade",
		weight = 0.8,

		onEquipItem = function(champion, slot)

							local pronoun = {["male"]="his",["female"]="her"} -- Gender word
							local hand = {["7"]="left", ["8"]="right"}		  -- left/right hand word
							hudPrint(" ") hudPrint(" ") hudPrint(" ") hudPrint(" ")			  -- clear the previous texts

							hudPrint(champion:getName().." holds the dagger ")
							hudPrint("in "..pronoun[champion:getSex()].." "..hand[tostring(slot)].." hand.")
							hudPrint("But it magically changes to an axe!")
							champion:removeItem(slot)
							champion:insertItem(slot, spawn("tricky_axe"))
							return false
							end,

	}
cloneObject{
	name = 'tricky_axe',
	baseObject = 'hand_axe',
	onUnequipItem = function(champion, slot)
						hudPrint(" ") hudPrint(" ") hudPrint(" ") hudPrint(" ")			  -- clear the previous texts

						hudPrint(champion:getName().." puts the axe away, but")
						hudPrint("it magically changes to a dagger again!")
						local newItem = spawn("dagger_hook")
						setMouseItem(newItem)
						end,
}
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Changing item descriptions on equip

Post by Eleven Warrior »

You can also do this with LOG Framework system by Jkos check it out
Post Reply