-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Programmable Logic Controller #816
base: master
Are you sure you want to change the base?
Programmable Logic Controller #816
Conversation
no way mlog ss14 |
public const int HIGH = 100; | ||
public const int LOW = 0; | ||
|
||
private string[] code = Array.Empty<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally these should be non-string as string comparisons can take a LOT of time, something like:
private string code = "";
private string instructions = Array.Empty<PLCInstruction>();
// ...
public class PLCInstruction
{
// yml hooks??? idfk maybe i'm getting WAY too inspired
public string Name = "Invalid";
public string Opcode = "nop";
public virtual void Run(PLCVar[] args)
{
//Logger.Info("Ran instruction " + self.Name);
return;
}
}
public class AddI : PLCInstruction
{
Name = "Add";
Opcode = "add";
public override void Run(PLCVar[] args)
{
if (args.Length < 3)
return;
args[2].SetValue(args[0].Value() + args[1].Value())
return;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code[] array is the actual text typed by the player, so I'd need to load it all in and then convert it to a separate array with instructions. Still have to check the strings, but then I do it only once instead of every step.
Probably a good idea, but I'm going to focus on getting it to work, and then optimising it after a working version is achieved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optionally throw NMIs instead of returning void lmao
probably some redundant casts now, will fix later
- type: entity | ||
id: PLC | ||
name: plc | ||
description: It's a programmable logic controller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should inherit from BaseStructure. Transform, Clickable, TnteractionOutline, Damageable will all be unnecessary as they are defined in BaseStructure.
Alternatively, you could create a machine board and make this inherit from BaseMachine - in that case you'll need to look into how other machines (e.g. autolathe) do it. It will eliminate the need for this entity to have its own unique construction graph/recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention is to keep it simple.
How do I inherit from BaseStructure? Do I just remove those types under components and replace them with one BaseStructure type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, add parent: BaseStructure
. Then navigate to the BaseStructure type, look what components it already has that were re-defined in your type, and remove them. If the parent entity defines a component but does not set up all the fields you want, you can still add the same component to the child entity and only set up the fields that were not set up in the parent entity. In that case, The rest of the fields will be inherited from the parent.
Is this being worked on? |
I try to figure things out now and then, but I haven't had time in the past few days. So, in short, it's had no progress on a while, but I haven't given up yet :P |
Description
A PLC, or Programmable Logic Controller, which interfaces with the wireless Device Linking system.
Build the PLC, write Spessembly code and have your PLC control and read from any attached devices.
You could use these PLC's to add dynamic behaviour to anything that you can link together with your multitool. Think airlocks that actually pump in or out air before cycling, more complex behaviour in conveyor belts, longer sequences of events when pressing buttons or levers, automating linked devices based on pressure, temperature, time, light intensity, etc. etc.
TODO
Media
Changelog
🆑 Alia Ash