Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Block scripts requests thread

Discussion in 'Programming (In-game)' started by TehGM, Jan 1, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. ErrJect Trainee Engineer

    Messages:
    17
    I have a couple ideas for a program block program, but not the knowledge to pull them off.
     
  2. GrindyGears Senior Engineer

    Messages:
    1,787
    With one antenna.
    You can see the where the antenna is with its signal. We could say you get the vector towards the bucket.
    Antenna itself provides you also with distance to the bucket. In other words you have all the information to know exactly where the bucket is.

    With 2 or more antennas

    You can get very rough estimation about the angle by comparing the positions of the 2 signals. Gor example if you see the signal dots on top of each other you know the bucket is aligned with vector going trough your line of sight.

    But i think piston muscles or rotors would give you better data of alignment of the bucket.[/QUOTE]

    Again, using that can give you very ambiguous answers there are a million possible positions that are 50m away from the cab, it doesn't really give you much to go on.

    and thats my script request... I would like to get a graphical representation of where EXACTLY my boom/bucket is using the rotors angles, or positions (or any means available) and if possible include the depth where i'm currently at.
     
  3. Sinbad Senior Engineer

    Messages:
    2,788
    @GrindyGears and @halipatsui, finding the exact orientation of the arm is the easy part, all the lengths and angles are readily available. Deapth is easy as well, its just a bit of geometry. These could all be output to a display as text. But thats not really intuitive without a few dozen hours of use to adapt to the display (ive seen plant operators who can glance at a screen full of numbers and know the state of their machine just because they have been looking at it long enough that its become intuitive) The hard part is the graphical representation. We dont have simple draw functions for the in game displays. The one or two scripts you have seen that look like they generate graphics are doing it the hard way, they shrink the display text size so that each character is a single pixel then build the image out of hundreds of text strings that are hundreds of characters long. They are basically emulating how a low resolution 1990s vga graphics processor works using the pb. And to be perfectly honest, while i know what is done i dont have a clue how its done without tanking sim speed.
     
  4. halipatsui Senior Engineer

    Messages:
    1,253
    Again, using that can give you very ambiguous answers there are a million possible positions that are 50m away from the cab, it doesn't really give you much to go on.

    and thats my script request... I would like to get a graphical representation of where EXACTLY my boom/bucket is using the rotors angles, or positions (or any means available) and if possible include the depth where i'm currently at.[/QUOTE]

    But if there is antenna signal you can see exactly the direction it is at :D

    In hud you can see the antenna signal which gives you both direction and distance.
     
  5. GrindyGears Senior Engineer

    Messages:
    1,787
    But if there is antenna signal you can see exactly the direction it is at :D

    In hud you can see the antenna signal which gives you both direction and distance.[/QUOTE]
    Okay, clearly something has been missed on your part, we are talking about an excavator with a (or so I plan) 100m reach, the cab is in a more or less fixed forward position, the DIRECTION is irrelevant because it's always assumed forward of the cab. From that fixed position looking out at an antenna on the bucket it's hard to see what the X and Y components are.

    Look at this like a right angle triangle with the hypotenuse being whatever the antenna reading is. We have no idea what the missing two sides are, and because the potential distance is fairly far, depth perception can get screwed up.
     
  6. halipatsui Senior Engineer

    Messages:
    1,253
    Okay, clearly something has been missed on your part, we are talking about an excavator with a (or so I plan) 100m reach, the cab is in a more or less fixed forward position, the DIRECTION is irrelevant because it's always assumed forward of the cab. From that fixed position looking out at an antenna on the bucket it's hard to see what the X and Y components are.

    Look at this like a right angle triangle with the hypotenuse being whatever the antenna reading is. We have no idea what the missing two sides are, and because the potential distance is fairly far, depth perception can get screwed up.[/QUOTE]

    You could also install antennas to the joints of the excavator. This way you could see where each joint is and have better awareness of the arms position.

    Even if the axis is fixed you get the y axis information from the cockpit.


    But yeah. It starts to seem like you are seeking somethibg else than what i am proposing :D
    But i hope it was any help.
     
  7. GrindyGears Senior Engineer

    Messages:
    1,787
    Hello All, I don't really know if this is supposed to be a "everybody gets one" type off thread, but i have (what i think is) a much simpler request:

    Could you possibly make it so that one of two things will happen:

    A) All items in a group get renamed and numbered to an argument in the PB?
    I'm working on a system that requires 200+ pistons and renaming them all one by one ensuring that don't miss any is a little time consuming (bonus points if it can number by subgrid?)

    B) All items in a given grid get named to one thing and numbered. (prioritizing pistons over rotors)

    for reference its constantly renaming these:

    [​IMG]
     
  8. halipatsui Senior Engineer

    Messages:
    1,253
    Have fun with that :D

    You could try easy automation. It has some renaming commands that can potentially be used to rename large amounts of components. Have not tried them myself tho.

    What real life part these are going to represent?

    If i were you i would probably group and name them on the go. You will be done sooner that way than waiting fir someone to script it for you.
     
  9. Wicorel Senior Engineer

    Messages:
    1,258
    Do you have an example BluePrint I could test with?
     
  10. GrindyGears Senior Engineer

    Messages:
    1,787
    Naming on the fly x 48 every time I want another set is far from ideal, plus I'm In no real rush.

    I'm not home at the moment, give me like 20 minutes,
    --- Automerge ---
    @Wicorel here's a blueprint for you http://steamcommunity.com/sharedfiles/filedetails/?id=880118908
     
  11. Wicorel Senior Engineer

    Messages:
    1,258
    Here's code that does SOMETHING like you want:

    There's two commands
    namegrids Name the grids in 'order' as "G##"
    Note: You can set sub-grids names yourself if you place a terminal block on the grid (like a control panel) and then Use the K menu 'info' tab to set the grid's name.
    Note2: you must own the majority of the blocks on the grid to change the name. The example BP has the pistons owned by 'nobody' so the name cannot be changed until ownership is changed.

    name names the rotors and pistons counting from 1 and up on each of the grids. Names them "<Gridname> : <rotor|piston> ##"


    [​IMG]
     
  12. GrindyGears Senior Engineer

    Messages:
    1,787
    Sorry if i sound like a bad customer here, but i think i may have slightly screwed my my description

    Would it be difficult to modify it to make the count continuous but having the individual "grids" be grouped?

    So there are 48 pistons in that example i gave, so i'd like 1 through 48, but i'd like each grid to be like 1-6, 7-12, 13-18 and so on.

    If it's too much trouble i can probably try and stumble through to make the change myself but i think you'd know it a bit better than I.
     
  13. Wicorel Senior Engineer

    Messages:
    1,258
    Yeah, easy change. But know that the grid order is kinda random so the numbering will not be from closest to furthest. On phone. I'll make the change when I'm back at computer
    --- Automerge ---
    Change the NameRotorsPistions() routine to be the following:

    Code:
    void NameRotorsPistons()
    {
    	Echo("Name Rotors & Pistons");
    	int i = 1;
    	foreach (var grid in localGrids)
    	{
    		List<IMyMotorStator> gridRotors = new List<IMyMotorStator>();
    		GridTerminalSystem.GetBlocksOfType<IMyMotorStator>(gridRotors, (x => x.CubeGrid == grid));
    		foreach(var rotor in gridRotors)
    		{
    			rotor.CustomName = grid.CustomName + " : Rotor " + i.ToString("00");
    			i++;
    		}
    		List<IMyMotorAdvancedStator> gridARotors = new List<IMyMotorAdvancedStator>();
    		GridTerminalSystem.GetBlocksOfType<IMyMotorAdvancedStator>(gridARotors, (x => x.CubeGrid == grid));
    		foreach (var rotor in gridARotors)
    		{
    			rotor.CustomName = grid.CustomName + " : Rotor " + i.ToString("00");
    			i++;
    		}
    		List<IMyPistonBase> gridPistons = new List<IMyPistonBase>();
    		GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(gridPistons, (x => x.CubeGrid == grid));
    		foreach (var piston in gridPistons)
    		{
    			piston.CustomName = grid.CustomName + " : Piston " + i.ToString("00");
    			i++;
    
    		}
    	}
    }
    
    
     
  14. Sabre One Trainee Engineer

    Messages:
    21
    So this is the default code for pirates in the game, which causes them to find/follow you. Would anybody be willing to modify this so the drones instead attempt to run into the player? I.E suicide attacks?

    Code:
    List<IMyTerminalBlock> list = new List<IMyTerminalBlock>();
    void Main(string argument)
    {
        Vector3D origin = new Vector3D(0, 0, 0);
        if (this.Storage == null || this.Storage == "")
        {
            origin = Me.GetPosition();
            this.Storage = origin.ToString();
        }
        else
        {
            Vector3D.TryParse(this.Storage, out origin);
        }
        GridTerminalSystem.GetBlocksOfType<IMyRemoteControl>(list);
        if (list.Count > 0)
        {
            var remote = list[0] as IMyRemoteControl;
            remote.ClearWaypoints();
            Vector3D player = new Vector3D(0, 0, 0);
            bool success = remote.GetNearestPlayer(out player);
            if (success)
            {
                bool gotoOrigin = false;
                GridTerminalSystem.GetBlocksOfType<IMyUserControllableGun>(list);
                if (list.Count == 0)
                {
                    gotoOrigin = true;
                }
                else
                {
                    bool hasUsableGun = false;
                    for (int i = 0; i < list.Count; ++i)
                    {
                        var weapon = list[i];
                        if (!weapon.IsFunctional) continue;
                        if (weapon.HasInventory() && !weapon.GetInventory(0).IsItemAt(0)) continue;
                        hasUsableGun = true;
                    }
                    if (!hasUsableGun)
                    {
                        gotoOrigin = true;
                    }
                }
                if (Vector3D.DistanceSquared(player, origin) > 20000 * 20000)
                {
                    gotoOrigin = true;
                }
                if (gotoOrigin)
                {
                    remote.AddWaypoint(origin, "Origin");
                }
                else
                {
                    remote.AddWaypoint(player, "Player");
                }
                remote.SetAutoPilotEnabled(true);
            }
        }
    }
     
  15. Ronin1973 Master Engineer

    Messages:
    4,945
    The bucket is always in the same vertical plane as the arm and through the center of the turret.

    If you place a remote block lined up with the arm, you can take readings as far as gravity vectors, etc. If you place another buried in the bucket, you can also take several readings from that. If the two remotes deflect from plane, you could possibly stop the rotation of the turret or change it's direction as the arm is probably being placed under lateral stresses from the bucket being caught on something.

    The remote on the bucket would definitely give you the orientation of the tool in absolute terms to the gravity vector. From there you could calculate the exact position of the bucket since the gravity vector drawn through both blocks will be parallel.


    As long as everything is connected via pistons/rotors, you should be able to pull the information and communicate. I take it the "bucket" is small block so a small antenna can be used? A beacon could do the job as well and only consume two blocks in either large or small grid.

    Sorry that I'm late on the conversation. Just brainstorming.
     
    • Like Like x 1
  16. Peavy Trainee Engineer

    Messages:
    47
    I need a really basic script that will find every timer block on a ship with a certain name to call trigger now
     
  17. halipatsui Senior Engineer

    Messages:
    1,253
    You might want to take a look at easyvautomation 2.0
     
  18. Peavy Trainee Engineer

    Messages:
    47
    I've looked at it but it's not what I'm looking for, I just need a script that will take every timer block with a certain name and trigger it.
     
  19. d4rky1989 Apprentice Engineer

    Messages:
    332
  20. halipatsui Senior Engineer

    Messages:
    1,253
    May i ask what kind of build you ae using it for?
     
  21. nubeees Trainee Engineer

    Messages:
    83
    Not sure how complicated this is, but it doesn't sound too difficult, so I'll toss it out there.
    I know using speed mods its possible to properly orbit a planet. However, due to the gravitational falloff Keen used for gameplay reasons, these orbits are highly unstable.
    So I was wondering, how hard would it be to create a script which maintains your orbit around a planet? :D
     
  22. Wicorel Senior Engineer

    Messages:
    1,258
    @Elfi Wolfe already has scripts that maintain altitude. But it's not really 'orbit'.

    I think somebody posted the math before.. I think they came to the conclusion that it's not really possible to do a 'real' orbit because of the way Keen does the math. Or maybe it would require a huge speed limit.
     
  23. halipatsui Senior Engineer

    Messages:
    1,253
    You should be able to do this with altitude aligner script from workshop.
    You dont even need a speedmod.
    With vanilla 20 km moons you can pretty much achieve orbit with 100 m/s limit. But it needs corrections to be sustainable.
     
  24. nubeees Trainee Engineer

    Messages:
    83
    I did mention speed mods for this purpose.

    That gravity aligner script (http://steamcommunity.com/sharedfiles/filedetails/?id=583272553&searchtext=altitude+aligner) would work pretty well, so really what I'm looking for is a script which takes altitude, planetary gravity (at sea level), gravitational falloff (I think its 7 in space engineers?) and determines the appropriate horizontal velocity.
    Basically a really fancy cruise control script.

    *edit
    fixed double post
     
  25. halipatsui Senior Engineer

    Messages:
    1,253
    You can use it to determine approppriate height when you are at max speed
     
  26. Elfi Wolfe Apprentice Engineer

    Messages:
    498
    I use my orbital script to hold altitude or g level and just give the satellite a push with the engines and let it drift around the world.
     
  27. halipatsui Senior Engineer

    Messages:
    1,253
    I make a script request for eadier raycast functionality based on how sensors are used.
    So:
    Anility to determine area of raycast in restricting angles and scan distance.

    Ability to modify scan frequency according to the scan distance.

    Ability to seperate which entities (ally,enemy,small ship, large ship etc.)trigger determined events.

    Ability to assign events what happens when raycast detects determined entity and when it does not.

    If someone happens to create this thank you very much :)
     
  28. Omen964 Trainee Engineer

    Messages:
    16
    So this script that DJ Arghlex's made i really love, i just would love some one to help me with adding to it so a thruster activates when turrets targets a enemy, I know there is no current function for that so i was thinking on if we could make the thruster activate if the ammo count drops.
    I have added the thruster to the script but have no idea how to make it check the inventory.

    Code:
    // DJ Arghlex's Turret-Guided Torpedo, v4
    
    // FEATURES
    // - Target acquisition by way of an on-board turret. Once fired, completely independent.
    // - precise aiming
    // - minimal involvement on the torpedo, so as to minimize interference with other systems.
    
    // INSTALLATION
    // - install a turret and a gyroscope so they both face the same direction, and upwards is the same direction for them.
    // - configure the rest of your torpedo's launch mechanisms (forward thrusters, dampener-thrusters, battery, auto-destruct timer, launch sequencing)
    // - turn off Idle Movement on the turret. this is important.
    // - make sure this script is being run with a timer block set to "Trigger Now" itself (or using Digi's Loop Computers to set it to "run every tick") when it's launched
    
    // CONFIG
    string turretName = "BEAM";	// Name your turret this.
    string gyroName = "GYRO";	// Name your gyroscope this.
    string thrustName = "THRUST";// Name your thruster this. -added by Omen
    float precision = 0.07F;	// Don't set too low or the torpedo will wiggle. Too high and it won't hit what it's trying to hit.
    int interval = 3;			// Run the script every this many ticks. Don't raise this unless you have to.
    
    // DO NOT TOUCH ANYTHING BELOW THIS LINE.
    
    // internal variables
    IMyLargeTurretBase b;
    IMyTerminalBlock g;
    IMyTerminalBlock f; //-added by Omen
    float lastAzimuth = 0;
    float lastElevation = 0;
    
    //moved all our block acquisitions so as to lighten engine load
    public Program() {
    	b = (IMyLargeTurretBase)GridTerminalSystem.GetBlockWithName(turretName);
    	g = GridTerminalSystem.GetBlockWithName(gyroName) as IMyTerminalBlock;
    f = GridTerminalSystem.GetBlockWithName(thrustName) as IMyTerminalBlock;
    	if (b == null){
    		Echo("ERROR! Name your guidance turret "+turretName);
    	}
    	if (g == null) {
    		Echo("ERROR! Name your gyroscope "+gyroName);
    	}
    if (f == null) { //-added by Omen
    		Echo("ERROR! Name your thruster "+thrustName); 
    	}
    }
    void setGyro(string t, int v) {
    	if (((IMyGyro)g).GyroOverride != true) {
    		g.GetActionWithName("Override").Apply(g);
    	}
    	float av=((float)v)*40F; //hardcoded because it stopped making sense to horse around with different values.
    	g.SetValueFloat(t,av);
    	Echo(gyroName+"/"+t+": "+v);
    }
    
    void AimAtTarget() {
    	Echo(b.Azimuth+"/"+b.Elevation);
    	if ( lastAzimuth != b.Azimuth || lastElevation != b.Elevation ) {
    		// our turret's angles changed. point us at the target.
    		if (b.Azimuth >= precision) {
    			setGyro("Yaw",-1);
    		} else if (b.Azimuth <= (float)(-1*precision)) {
    			setGyro("Yaw",1);
    		} else {
    			setGyro("Yaw",0);
    		}
    		if (b.Elevation >= precision) {
    			setGyro("Pitch",1);
    		} else if (b.Elevation <= (float)(-1*precision)) {
    			setGyro("Pitch",-1);
    		} else{
    			setGyro("Pitch",0);
    		}
    		//setGyro("Roll",1); // does not work. completely breaks turret's targetting. do not reenable
    	} else {
    		//turret angles didn't change. lock out our gyro so we don't whirl around.
    		setGyro("Pitch",0);
    		setGyro("Roll",0);
    		setGyro("Yaw",0);
    f.SetValueFloat("Override", 12000f); //Activate Thruster -added by Omen
    	}
    	lastAzimuth=b.Azimuth;
    	lastElevation=b.Elevation;
    }
    
    //decides wether we want to run the program every tick or not.
    int clock=0;
    void Main() {
    	if (clock % interval == 0) {
    		AimAtTarget();
    		clock=0;
    	}
    	clock=clock+1;
    }
    
    Thanks in before hands.
     
  29. macgeifer Apprentice Engineer

    Messages:
    139
    Hey guys,

    here is another request (i am quite sure someone already did this but i cant find it)

    I am looking for a script which detects the actual flight direction in space (dampeners off) and aligns the ship backwards for reverse thrust. They plan is to have only small thrusters for slow speed movement in all directions but powerful forward thrusters which can be used also for braking. Turning the ship by hand is way too inaccurate for me.

    Thx so far
    Mac
     
  30. nubeees Trainee Engineer

    Messages:
    83
    How hard would it be to create a mech/walker leg manager script? I feel like that would make front page in a day! :)

    It might be a little too complicated, but I'm just throwing the idea out there if anyone wants to take it on
     
Thread Status:
This last post in this thread was made more than 31 days old.