Skip to content

Instantly share code, notes, and snippets.

@hmmdeif
hmmdeif / solar_farm_sun_finder.cs
Last active August 9, 2023 11:04
Space Engineers script to rotate a main solar panel to check for the rotation of the sun. Once the output is high enough, the rotors will stop spinning until the max output falls below the threshold.
void Main(string argument)
{
List<IMyTerminalBlock> solarRotors = new List<IMyTerminalBlock>();
IMySolarPanel mainSolarPanel = GridTerminalSystem.GetBlockWithName("Main Solar Panel Optimised") as IMySolarPanel;
int currentPower = GetPanelPower(mainSolarPanel);
GridTerminalSystem.SearchBlocksOfName("Solar Rotor", solarRotors);
if (currentPower <= 100) {
RotateSolarRotors(solarRotors);
@hmmdeif
hmmdeif / helpers.ts
Last active September 27, 2023 05:36
Hardhat calculate bytes4 interface
// Import contract factory generated from `hardhat compile` with typechain
import { IERC165__factory, IERC2981__factory } from '@custom-types/contracts'
import { ethers } from 'hardhat'
import { utils } from 'ethers'
const getInterfaceID = (contractInterface: utils.Interface) => {
let interfaceID = ethers.constants.Zero;
const functions: string[] = Object.keys(contractInterface.functions);
for (let i = 0; i < functions.length; i++) {