Page 1 of 1

No such node, but same code works else where.

Posted: Wed Mar 30, 2016 8:12 am
by xnenai
So I'm trying to utilize the following code for an 'item' file. I already use this code for 'technology' files and I have no problems, but when I use it for 'item' I get the following message on start up: "Error while loading item prototype (steel-axe-t1): No such node (stack_size / damage / durability / speed)"

Code: Select all

require "defines"
require "util"
require ("stats")

	da = stats.steelAxe.da
	du = stats.steelAxe.du
	sp = stats.steelAxe.sp
	ss = stats.steelAxe.ss

data:extend(
{
  {
    type = "mining-tool",
    name = "steel-axe-t1",
    icon = "__zerxethia__/graphics/icons/steel-axe-t1.png",
    flags = {"goes-to-main-inventory"},
    action =
    {
      type="direct",
      action_delivery =
      {
        type = "instant",
        target_effects =
        {
            type = "damage",
            damage = { amount = da, type = "physical"}
        }
      }
    },
    durability = du,
    subgroup = "tool",
    order = "a[mining]-b[steel-axe-t1]",
    speed = sp,
    stack_size = ss,
  },


---stats.lua
stats = {
	steelAxe = {
		da = 8,
		du = 5000,
		sp = 4
		ss = 100,
	}
}

Re: No such node, but same code works else where.

Posted: Wed Mar 30, 2016 11:14 am
by daniel34
You are missing a comma (,) in stats.lua after sp = 4, then the code works.

And the item.lua is missing a }) at the end, but I guess that was an error when copying the code into the forums.

See the mod I attached.
(use /c game.local_player.insert{name="steel-axe-t1", count="1"} in a game to test the item)

Re: No such node, but same code works else where.

Posted: Wed Mar 30, 2016 3:31 pm
by xnenai
Yea it's still giving me problems. It will work if I assign the values locally in the file:

Code: Select all

   
   da = 8 --stats.steelAxe.da
   du = 5000 --stats.steelAxe.du
   sp = 4 --stats.steelAxe.sp
   ss = 20 --stats.steelAxe.ss
but for some reason it just isn't reading the stats.lua

Re: No such node, but same code works else where.

Posted: Wed Mar 30, 2016 6:36 pm
by xnenai
As far as I know, it's just not reading the file at all. They're both in the same folder, the require is implemented. I've copy and pasted all applicable relevant code from my technology files , where it works just fine, but doesn't work in the item files. I tried doing some basic arithmetic on the values that the item file is supposed to read from the stats file and the game is tells me that I can't do arithmetic on these values because they are nil, which they're not, they've been assigned values in the stats file which is read by the item file and assigned to local variables to use in it.