Author Topic: Transfering variables from one placable to another?  (Read 333 times)

Legacy_Loathesome Pickle

  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
Transfering variables from one placable to another?
« on: February 26, 2012, 08:43:15 pm »


               Hey there,

 I am trying to simulate a farming experience for a little 'for funsy' module I'm making however I'm running into a problem when I try to create a new object over the old one, I don't know how to transfer the variables over without assigning new tags to the created object which isn't practical as this script will be run many times, often in the same area and unless I can come up with some kind of progressive tagging system, I can't imagine a way that could be made feasable.

 My idea on this is that a developer could make new seed items for the players to use and assign a variable on the seed that would indentify its type (IE: Crop, bush or tree) and  the kind of fruit/vegitable it yields. From there the script would take over and handle the rest, including spawning progressively larger trees/crops/etc until it finally makes the harvestable one where players can take the resulting yield.

 Ideally, there would be no more than 4 stages. From planting, seedling (visible bush/tree/whatever), moderate growth and then the harvestable product.

 Does anyone have any ideas they could point me to? I've been at this for a while but I've run out of ideas.

 Thanks!

 -Dill.

  
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Transfering variables from one placable to another?
« Reply #1 on: February 26, 2012, 09:27:14 pm »


               Parts of what you're doing are likely similar to what Rolo Kipp had been working towards here: http://social.biowar...index/8875858/1

That's more geared to growth of forests than specific plants, but the core principles are the same I think.

As for transferring variables directly, when they're unspecified, you'd need nwnx for that.

 If you know what they are, you can just get the variables off the old placeable, destroy it, create the new placeable using the values retrieved, and then set them to the new one on a slight delay.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Transfering variables from one placable to another?
« Reply #2 on: February 26, 2012, 10:26:41 pm »


               When I want to track data related to an object which is created, destroyed, and then created again, I find it easier to store the data somewhere else than the object itself. In your case, this would mean that the plant data is not destroyed when the "plant" object is.

In order to associate the data with the object you need a pointer on the plant object to the data object, and perhaps from the data object to the plant. OR you can use some variable naming scheme that enables you to associate the data to the specific plant. Each plant for example would use a unique prefix on its data string.

Anyway, I find this approach much easier than copying all the data from one object to the next.

HOWEVER - another way to solve your specific problem would be to encode the unfolding sequence in the seed's tag, and write a script which understands how to make use of it. So if you have four stages of growth, seperate the tag into a prefix and four sub tags or sections. The prefix would track the stage of growth, and the four subsections would describe wha happens in each growth stage. In essence the tag itself would be a "genetic" code. And the script would know what to do with the genetics.
               
               

               


                     Modifié par henesua, 26 février 2012 - 10:32 .
                     
                  


            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Transfering variables from one placable to another?
« Reply #3 on: February 27, 2012, 05:05:06 am »


               You could make an invisible object to store the data on. Associate the seed or plant or whatever to the invisible object by tag, or some other appropriate means. When you destroy it, all you'd have to do is associate the new item to the same invis object that the one being destroyed is associated with.

A better way would be not to destroy it at all. Instead just change its appearance.
               
               

               
            

Legacy_Loathesome Pickle

  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
Transfering variables from one placable to another?
« Reply #4 on: February 27, 2012, 04:59:42 pm »


               Thanks for the replies everyone, very helpful and interesting. Never thought about the 'genetic code' idea but it's something I'll be chewing on. '<img'>

Axe_Murderer: Is there a way to modify a placable's appearance? I was under the impression it wasn't possible, at least I couldn't find anything on it. Maybe I didn't look hard enough.