No such node, but same code works else where.

Place to get help with not working mods / modding interface.
xnenai
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Mar 26, 2016 9:05 am
Contact:

No such node, but same code works else where.

Post 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,
	}
}
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

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

Post 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)
Attachments
empty_0.0.1.zip
(1.55 KiB) Downloaded 77 times
quick links: log file | graphical issues | wiki
xnenai
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Mar 26, 2016 9:05 am
Contact:

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

Post 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
xnenai
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Mar 26, 2016 9:05 am
Contact:

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

Post 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.
Post Reply

Return to “Modding help”