playMaker

Author Topic: Looking for Best Practice: Blackbox Functions  (Read 2451 times)

tinjaw

  • Playmaker Newbie
  • *
  • Posts: 24
Looking for Best Practice: Blackbox Functions
« on: January 29, 2014, 04:47:53 PM »
I am new to Playmaker and not familiar with the proper idioms for building things. I was hoping somebody could point me in the right direction.

I have to take a set of six numbers and run them through some computations. In standard programming I would make a function, call it with parameters, and return with values.

I don't know the proper way to do this in Playmaker. I can create a Game Object and attach a FSM to it and then sent it an event with global variables, however there is no way to have it return without hard wiring it. I am certain that this is not the way to do it.

I probably haven't provided enough information to fully explain my question, but I will be happy to elaborate if somebody can help.

Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Looking for Best Practice: Blackbox Functions
« Reply #1 on: January 29, 2014, 04:55:16 PM »
Are you trying to send data from a Script to an FSM?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

tinjaw

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Looking for Best Practice: Blackbox Functions
« Reply #2 on: January 29, 2014, 08:26:07 PM »
Are you trying to send data from a Script to an FSM?

No scripts. I have used Playmaker to read in values (constants) from PlayerPrefs and gotten some input using Playmaker actions with Daikon Forge. Now I need to do a series of calculations. They will be somewhat complicated and I don't want to just cut and paste, as then I will need to update in a bunch of places. I want to keep it DRY.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Looking for Best Practice: Blackbox Functions
« Reply #3 on: January 30, 2014, 05:20:37 AM »
Hi,

 what are the operation at stake? it's difficult to give a solution without knowing precisly what you want to perform on them numbers.

bye,

 Jean

tinjaw

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Looking for Best Practice: Blackbox Functions
« Reply #4 on: January 31, 2014, 11:28:59 AM »
I have five sectors. The player provides three values for each sector.

For each sector I take the three variables, use the variables to look up some values. Then I take the values and the looked up values and perform a series of calculations on them resulting in a single result.

I don't want to have to copy and paste the lookups and calculations for each sector. I want to encapsulate that functionality in a state and then call it five times with parameters.

Does that help or do I need to get more specific?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Looking for Best Practice: Blackbox Functions
« Reply #5 on: February 03, 2014, 05:08:41 AM »
Hi,

 ok, have you considered arrayMaker?

https://hutonggames.fogbugz.com/default.asp?W715

that would be a very case for this. ArrayMaker will allow you to reference all these sectors and their respective 3 variables

the other possibility is to create this structure using dummy gameobjects and fsm acting as interfaces and data repositories.

so you would create an empty gameobject, call it sector 1, and an fsm would be on it, with 3 variables, value 1, value 2 and value 3.

then that fsm can do operation on them and return /store values on top of that, other fsm would keep a reference of the gameobject "Sector x" and send event to it, or simply use "get fsm xxx" to find out about a particular value.

 that's "blackbox" enough for me in most cases.

bye,

 Jean