Jump to content

Help with hearth fires planters script please.


smashly

Recommended Posts

Hi,

Thank for taking the time to read my help request.

 

I wrote a little mod to be able to drop plots of hearth fires soil anywhere on the map.

The script is working fine ftm, but I'm trying to tidy it up a little.

 

The problem I had was getting the soil to be ready to plant in as soon as dropped without leaving and returning to the cell that the planter soil is dropped in.

 

So a nasty work around was I duplicated the contents of an OnCellAttach() event in to a standard function in the native BYOHPlanterSoilScript.src and compiled it.

 

Then I added the BYOHPlanterSoilScript as an import in my script and called the added function from my script when I spawn the soil in the cell a user wants it in.

Sure enough the soil can be used strait away as soon as dropped.

I really didn't want to handle the growing side of things in my mod, just the soil spawn and moving.

 

But my absolute lack of understanding in object orientated scripting is telling me it's not the way to do it even though it works.

 

You still here...

Well after that story, how do I make the equivalent call to make my soil work without adding a wrapped function in the original BYOHPlanterSoilScript.

 

This is from the BYOHPlanterSoilScript:

EVENT OnCellAttach()
    debug.trace(self + " OnCellAttach")
    if AlreadyLoaded == FALSE
        debug.trace(self + " OnCellAttach: DO ONCE")
        objSelf = self
        PlanterContainer = GetLinkedRef()
        (PlanterContainer as BYOHPlanterContainerScript).mySoilRef = objSelf
        AlreadyLoaded = TRUE
    endif
    (PlanterContainer as BYOHPlanterContainerScript).GrowPlantedItem()
endEVENT

This is what I added to the BYOHPlanterSoilScript

function setmysoil()
    if AlreadyLoaded == FALSE
        objSelf = self
        PlanterContainer = GetLinkedRef()
        (PlanterContainer as BYOHPlanterContainerScript).mySoilRef = objSelf
        AlreadyLoaded = TRUE
    endif
    (PlanterContainer as BYOHPlanterContainerScript).GrowPlantedItem()
endfunction

This is how I call the setmysoil() from my script

(CurStatic as BYOHPlanterSoilScript).setmysoil()

(CurStatic is my ObjectReference property to my current soil).

 

As you can see I'm really lost at object orientated scripting.

Flat api scripting not a problem (autoit is the only scripting I ever done or used, single threaded no objects apart from object wrapper scripts)

 

Any constructive input is appreciated.

Thank you for reading to the end :smile:

Edited by smashly
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...