eronoobos / BABAR-The-Shardifant

Balanced Annihilation & Balanced Annilhation Reloaded configuration for Shard
2 stars 1 forks source link

share data guideline #42

Open pandaro opened 8 years ago

pandaro commented 8 years ago

correct way to pass information between: module to module behaviour to behaviour module to behaviour behaviour to module so i need to share data from a new factorybuildershandler module to taskqueuebehaviour behaviour i reach in the module a factory, a position and builder id i need to take this data inside progressqueue and check if the builder id == then do factory in the give point. but in general, there are a guideline for sharing data?

eronoobos commented 8 years ago

There are a lot of examples in this repo. Where practical, use functions inside the module to export data outside of it (to behaviours and to other modules). For example https://github.com/eronoobos/BABAR-The-Shardifant/blob/5f0c408a13f11d18e401d8851569af273dc92c47/cleanhandler.lua#L86 is used by https://github.com/eronoobos/BABAR-The-Shardifant/blob/5f0c408a13f11d18e401d8851569af273dc92c47/cleanerbehaviour.lua#L92

It is also a good idea I think to have modules call a behaviour's function rather than accessing parts the behaviour's data directly.

One rigid guideline: Do not pass information between behaviours. This can be done with a module as a mediator.

It sounds like your problem can be solved by simply creating a function inside factorybuildershandler that takes a builder id as an argument, and returns a position (and a factory name?). taskqueuebehaviour would then just call this function from within ProgressQueue with self.ai.factorybuildershandler:CallThisFunctionSomething(self.unit:Internal():ID())

pandaro commented 8 years ago

oops maybe, cause my great newbie-ism i cause a lot of problem. maybe, when i misunderstand the correct way to load variables inside ai. / self.ai. / self.ai.behaviour / self.ai.handler. i make a great amount of fail... correct me now if there are a lot of work to redo: take an example from :here : i set a variable called self.ai.variable but here "self" is the factory! maybe a lots of problem now are in the behaviours files where i use wrong "self" sorry

eronoobos commented 8 years ago

That's all fine! That's how it ought to be written. Behaviours and modules all have .ai, their ai instance.