Page 1 of 1

Prototype properties as functions?

Posted: Tue Jul 05, 2016 4:22 pm
by Vulcan
I'm going to guess that setting the property of a prototype as a function to be determined at runtime is not possible, like this:

Code: Select all

  {
    type = "item",
    name = "an-item",
    icon = "__modmodmod__/graphics/icons/thing.png",
    stack_size = some_function()
  }
As I said, I don't think this will work but I'd like confirmation because it would make my life easier if it did, but I don't want to go marching off down a dead end if it can be avoided

Thanks!

Re: Prototype properties as functions?

Posted: Tue Jul 05, 2016 4:41 pm
by Zeblote
Well, it does work, but the function will be evaluated when creating the prototype. So it probably doesn't do what you want?

Re: Prototype properties as functions?

Posted: Wed Jul 06, 2016 8:15 am
by Vulcan
That's what I thought, my question referred to the function being evaluated each time the property is accessed, rather than once when all the prototypes are created.
Thanks for clearing this up!