EU Calculator

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Dybbuk

New Member
Jul 29, 2019
12
0
0
Hmm...I've a suggestion for you. It seems, from your code, that you plan to make adding more machines less of a bother. All well and good, however, I believe I've a method that'd work better, and allow you to design a tool that'd let you easily (and quickly) create new machines that can be plugged into the program at runtime. My suggestion involves serialization. Basically, what you'd have is a single class that'd represent a generic machine: a name, EU/t output, configurable output, etc. Something like...

Code:
using System;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
 
[Serializable()]
public sealed class Machine : ISerializable
{
  public string Name;
  public int    EUOut;
  public bool  ConfigOutput; //Can the optput be configured by the user?
 
  public Machine()
  {
    this.Name        = "Generic Machine";
    this.EUOut        = 16;
    this.ConfigOutput = false;
  }
 
  public Machine( Machine other )
  {
    this.Name        = other.Name;
    this.EUOut        = other.EUOut;
    this.ConfigOutput = other.ConfigOutput;
  }
 
  // Deserialization constructor, this is called
  //  when we use the deserialization method in
  //  our main program code, as detailed later.
  public Machine( SerializationInfo info, StreamingContext ctxt )
  {
    this.Name        = (string) info.GetValue( "Name",        typeof( string ) );
    this.EUOut        = (int  ) info.GetValue( "EUOut",        typeof( int    ) );
    this.ConfigOutput = (bool  ) info.GetValue( "ConfigOutput", typeof( bool  ) );
  }
 
  // Serialization function.  This is called
  //  automatically when we use the serialization
  //  method in the tool code, as detailed later.
  public void GetObjectData( Serialization info, StreamingContext ctxt )
  {
    info.AddValue( "Name",        this.Name        );
    info.AddValue( "EUOut",        this.EUOut        );
    info.AddValue( "ConfigOutput", this.ConfigOutput );
  }
}

Now, when you get to your actual form/tool code, you'd want somethin like...

Code:
// Form code for deserialization.
//  Requires System.Runtime.Serialization,
//  System.Runtime.Serialization.Formatters.Binary, and
//  System.IO
 
Stream          stream    = File.Open( filename, FileMode.Open );
BinaryFormatter formatter = new BinaryFormatter();
 
Machine machine = (Machine) formatter.Deserialize( stream );
 
 
 
// Tool code for serialization.  Has the
//  same requirements as deserialization.
//  Assumes you have a local variable called
//  "machine" of type Machine.
 
Stream          stream    = File.Open( filename, FileMode.OpenOrCreate );
BinaryFormatter formatter = new BinaryFormatter();
 
formatter.Serialize( stream, machine );

Probably know all this, but I figured I'd throw in my $0.02. I've used this method before with several projects, and lemme tell ya, it saves a lot of time and frustration when it comes to scripting your programs and making 'em more flexible.

Thank you for the suggestion - I've thought of this, but I decided to do a multidimensional array instead (For now).

I've made two array that handle IC2/Greg machines separately - At the moment my goal is to show EU/t total, and maybe in the future total amount of EU produced (Example - When a certain generator receives a certain fuel, it produces more EU within those ticks.)
So in that thought - When I eventually do allow the ability to show total EU, along with being able to change fuels... I might look into serialization again, or trying reading XML files that contain modifiers.

At this moment of development, I want to code functionality, and then improve it later. I did however change my system on adding machines, and assigning their max EU/t outputs.
 

RavynousHunter

New Member
Jul 29, 2019
2,784
-3
1
Aye, tis understandable. Gettin it done right comes first, rule #1. I've always found XML to be more trouble than its worth, personally...there's nothing I could use it for that serialization couldn't handle much, much more simply and easily.
 

Dybbuk

New Member
Jul 29, 2019
12
0
0
Big update! All machines are in, except for both reactors. Major overhaul on on a lot of systems, added another team member who might speed thing up!
 

San

New Member
Jul 29, 2019
94
0
0
After you added the dynamic calculations and removed the "Calculate" button it allows you to input negative numbers again.

Also, technically the magic energy absorber has varriable output values, 128 for aura conversion and 32 for ender crystal power and perhaps another for stripping items of their enchantments. I think the main use of the absorber is to turn aura into EU, so it's probably not a big deal, but perhaps something to look into.
 

NovaSkye

New Member
Jul 29, 2019
4
0
0
It been awhile since I looked at this, and now it looks SO much better! I still looooove how easy it is to figure out and how simple it is to use. Love all the new added machines and other things!
 

Dybbuk

New Member
Jul 29, 2019
12
0
0
Sorry for no new updates, the download number still grow. Version 0.4.0 is currently in development.

A lot has changed! A lot of code rewrites, looks smoother, and tons of additional content.

Currently we're coding machines that require energy, and storage machines. We're also trying to add "fuels" into this version, but may be halted for version 0.5.0.