Page 1 of 1

TorchItem Component issues?

Posted: Fri Nov 21, 2014 7:14 pm
by MadCatter
I've been trying to create a lantern item (definition below), but when I pick up the item it results in this error:

What am I doing wrong? I have tried defining fuel amounts as well but to no avail. Is it an issue with my syntax?

Previously I used baseObject = "torch_everburning" but that resulted in item atlas glitches when it automatially increments the index on equip.

Image

Item Definition:
SpoilerShow

Code: Select all

defineObject{
   name = "hand_lantern",
   baseObject = "base_item",
      components = {
      {
         class = "Model",
         model = "mod_assets/models/sx_lantern.fbx",
      },
	  {
         class ="Item",
         uiName = "Lantern",
		 gfxAtlas = "mod_assets/textures/items_atlas.dds",
         gfxIndex = 0,
		 GfxIndexPowerAttack = 1,
         secondaryAction = "Fire_Blast",
		 impactSound = "impact_blade",
         weight = 3,
         traits = { "item" },
         description = "An old oil lantern.",
      },
{
		 class ="TorchItem",
		 onEquipItem =
			function()
				self.go.torch:setType("spot")
self.go.torch:enable()
			end,
	  },
	  {
         class = "MeleeAttack",
         attackPower = 5,
         attackSound = "impact_blade",
         cooldown = 3.0,
         baseDamageStat = "strength",
         damageType = "physical",
      },
	  {
        class = "CastSpell",         
        name = "Fire_Blast",
		uiName = "Fire Blast",
		spell = "fireburst",
		repeatCount = 0,
		cooldown = 6,
        energyCost = 30,
	  },
   },
   editorIcon = 24,
}
Thanks to anyone who can help.

Re: TorchItem Component issues?

Posted: Fri Nov 21, 2014 7:19 pm
by NutJob
add "fuel = 1100," to torchitem class, perhaps, then try again.

May need to update that amount every so often so it doesn't burn out.

Edit: or maybe "fuel = inf" for infinity? I just looked that one up in John's Primitive asset definitions.

Re: TorchItem Component issues?

Posted: Fri Nov 21, 2014 7:22 pm
by Batty
I get the same error if I have this line:

Code: Select all

party.party:getChampion(1):insertItem(2, spawn("torch").item)
even though I 'cleaned' the party's inventory out first. Strange thing is if I press play after the error, the editor starts and champion(1) has a torch in hand (but it crashes if exported).

I have no problem inserting any other items into the party's inventory, only the torch, so maybe this is related to MadCatter's error.

Re: TorchItem Component issues?

Posted: Fri Nov 21, 2014 7:42 pm
by MadCatter
NutJob wrote:add "fuel = 1100," to torchitem class, perhaps, then try again.

May need to update that amount every so often so it doesn't burn out.

Edit: or maybe "fuel = inf" for infinity? I just looked that one up in John's Primitive asset definitions.
Can't believe it was that simple, thanks. :D

"inf" didn't seem to work, so I substituted it for "math.huge" which seems to be standard in lua.

However, now I have another problem. Adding a torch component to an item makes the item atlas index increment by one when it is equipped, and has a vertical offset of the image. I'm assuming this is due to some code that comes bundled with the class, but is there any way to disable that?
You can see in the image below, both icons are shifted down a small amount.
SpoilerShow
Image

Re: TorchItem Component issues?

Posted: Fri Nov 21, 2014 8:04 pm
by NutJob
Perhaps something to do with being a weapon and weapons get shoved down so they take up the entire slot? GUI isn't something I've even looked into yet with the editor. =)

AKA I have no idea.

Re: TorchItem Component issues?

Posted: Fri Nov 21, 2014 8:15 pm
by MadCatter
Could be. I'll just have a fiddle with the item atlas and see if I can adjust it there so it ends up in the right place.
GUI meddling can wait until some other time :D
Thanks.

Re: TorchItem Component issues?

Posted: Thu Dec 25, 2014 8:24 pm
by Periodiko
How is this going? I created a torch item with a similar approach - it's a magic staff that's supposed to radiate torchlight - but in-game the item weirdly replaces the base graphics with a normal torch. I'm not really sure how to proceed.

Re: TorchItem Component issues?

Posted: Fri Dec 26, 2014 2:17 am
by MadCatter
I think you want to use the following functions in your item definition. The gfxIndexInHand is the one that is changing the texture when you equip it.

Code: Select all

gfxIndex(number)          Set index of icon in texture atlas
gfxIndexInHand(number)          Set index of in-hand icon
gfxIndexPowerAttack(number)          Set index of charging power attack icon
Strangely though, there doesn't seem to be anything in the definition of the torch item which is odd. I assume it's handled inside the torchItemComponent which seems to automatically increment the gfx index by 1 when you equip the item, and puts it out in water (may be an issue if you want to use your staff underwater).

Re: TorchItem Component issues?

Posted: Fri Dec 26, 2014 3:00 am
by minmay
It doesn't just increment it by 1, it changes it depending on the fuel level. The "torch" item uses indices 130 (not lit), 131 (lit, brightest), 132, 133, 134, 135 (burnt out), and 104 (used).