Jump to content

How to created large amount of Filter/Buffer gate in a programable way?


Recommended Posts

I made a digital piano with 44 keys last year,here is the video.

https://www.bilibili.com/video/BV1MJ411B7oZ/

https://www.bilibili.com/video/av78037533

<p><iframe src="//player.bilibili.com/player.html?aid=78037533&amp;bvid=BV1MJ411B7oZ&amp;cid=133509524&amp;page=1" frameborder="no" scrolling="no" width="95%" height="600"> </iframe></p>

But the problem is storing data for this equipment require huge amount of Filter/Buffer gates and lots of maunal editing. So I need a way to quickly read data from a midi file and convert them to game Filer/Buffer gates configuation.The template yaml method doesn't work because the time setting is not recoreded in those file and timing in music is critical.

Anyone can shed some light?

Link to comment
Share on other sites

Interesting App but my challenge is to make things within ONI physics boundaries. So the sound has to be generated by the game sound effect and the data has to be stored by logic gates, no MOD allowed. Looks like I have publish my next video by painstakingly edit gates by gates.

Link to comment
Share on other sites

Tried patch this piece of code in harmony and It seems enable template loader in recongnise buffer gate delay time.

 

        [HarmonyPatch(typeof(TemplateLoader))]
        [HarmonyPatch("PlaceBuilding")]
        public class TemplateLoader_PlaceBuilding_Patch
        {
            public static bool Prefix(ref GameObject __result, Prefab prefab, int root_cell)
            {
                Debug.Log("TemplateLoader PlaceBuilding Prefix!");
				.....

                if (prefab.other_values != null)
                {
                  foreach (Prefab.template_amount_value otherValue in prefab.other_values)
                  {
                    string id = otherValue.id;
                    if (!(id == "joulesAvailable"))
                    {
                      if (!(id == "sealedDoorDirection"))
                      {
                                    if (id == "switchSetting")
                                    {
                                        LogicSwitch s = gameObject1.GetComponent<LogicSwitch>();
                                        if ((bool)(UnityEngine.Object)s && (s.IsSwitchedOn && (double)otherValue.value == 0.0 || !s.IsSwitchedOn && (double)otherValue.value == 1.0))
                                            s.SetFirstFrameCallback((System.Action)(() => s.HandleToggle()));
                                    }
                                    else if (id == "delayAmount")
                                    {
                                    Debug.Log("Delay Amount set to " + otherValue.value);
                                        LogicGateBuffer component4 = gameObject1.GetComponent<LogicGateBuffer>();
                                        if ((bool)(UnityEngine.Object)component4)
                                            component4.DelayAmount = otherValue.value;

                                    }
                                    else { }

                      }
                      else
                      {
                        Unsealable component4 = gameObject1.GetComponent<Unsealable>();
                        if ((bool) (UnityEngine.Object) component4)
                          component4.facingRight = (double) otherValue.value != 0.0;
                      }
                    }
                    else
                    {
                      Battery component4 = gameObject1.GetComponent<Battery>();
                      if ((bool) (UnityEngine.Object) component4)
                        component4.AddEnergy(otherValue.value);
                    }
                  }
                }


				.......
                  
                if (prefab.connections != 0)
                  TemplateLoader.PlaceUtilityConnection(gameObject1, prefab, root_cell);
                __result = gameObject1;

                return false;

            }
        }

    }
}

Also edit yaml file like this

name: Gate_Test
info:
  size:
    X: 2
    Y: 1
  area: 2
cells:
- element: Oxygen
  mass: 6.68891478
  temperature: 192.216827
- element: Oxygen
  mass: 6.90753126
  temperature: 208.156052
  location_x: 1
buildings:
- id: LogicGateBUFFER
  element: Copper
  temperature: 293.149994
  other_values: 
  - id: delayAmount
    value: 1.23

Now it is just a matter of refine this code and edit the yaml file

Link to comment
Share on other sites

On 5/28/2021 at 1:55 PM, shadow_wxh said:

Interesting App but my challenge is to make things within ONI physics boundaries. So the sound has to be generated by the game sound effect and the data has to be stored by logic gates, no MOD allowed. Looks like I have publish my next video by painstakingly edit gates by gates.

app is for transfer midi or some other info to the game, but as i understand you want make it like game poi is  maded what stored inside yaml file

Link to comment
Share on other sites

Something like that, another way I can think of is to prase game sav file and edit from there but I haven't figure out how to do that yet. Anyway the limit is not to change the game physics this is only mean to reduce manual labour.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...