This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

so I have been following a tutorial on building a farm sim,(https://www.youtube.com/watch?v=WtlJgdCPJ4k&ab_channel=SmallNap)
I followed his directions to a T and despite his working mine is not as I keep getting a non-existant func "initialize" despite the func being called in a child script. I am fairly new to coding and have tried every which way to solve this issue to no avail. here is the error "Invalid call. Nonexistent function 'initialize' in base 'StaticBody2D'."
I will also attach the script bellow the first two being from the Base Scene and the last from the scene I am trying to instance.
Thank you in advance to anyone that can help!

  • var cropdata = {"pk": 1,
    "objectname":"Weed",
    "phase
    days": [1,2,2,2,INF],
    "currentphase": 0,
    "day
    ofcurrentphase": 0,
    "crop_age": 0}

  • func input(event):
    if event.is
    actionpressed("Plant"):
    var crop
    path = "res://DrugLordSim proj/Crops/Weed.tscn"
    var crop = load(croppath).instance()
    crop.initialize(
    cropdata)
    crop.global
    position = tileposinfrontofplayer * 32
    add_child(crop)

    • func initialize(cropdata):
      .initialize(cropdata)
      phasedays = _cropdata.get("phase_days")
in Engine by (12 points)
reshown by

initialize() is called in several places of your code here. Which one is failing?

it is the line:
crop.initialize(cropdata)

Woo I managed to fix it now thanks for a quick reply

You should add the solution to this question so that any other user who encounters a similar problem in future can get a solution here :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.