Space Engineers

Space Engineers

XPAR Mimir (OBSOLETE)
Animal Jul 11, 2015 @ 5:59am
Using Mimir to replace complex Timer structures(Timer bools, Timer delay emulation)
So far I love this thing, but i've hit my first quandry. I use some of the timer's on and off states as bools and mode switches (turn one off and another on to change behaviors and break from a loop)

Can Logic be called from the Cached Commands? Same with setting variables.

Likewise is there a way for logic to call a cached command?

if so this thing will be able to replace ALL of my timres
< >
Showing 1-13 of 13 comments
Animal Jul 11, 2015 @ 6:01am 
Except the Heartbeat of course
Craig P  [developer] Jul 11, 2015 @ 6:32am 
You can use the line

Apply("Some Cached Command")

in the logic or UI function, it'll work fine. In fact, you can call cached commands from within cached commands.

But calling logic or UI functions from within a cached command is a serious recursion risk - what are you trying to do? There's probably a better way to do it.

To set an arbitrary boolean, use

Set("Arbitrary boolean of any name") in the code, or
"Set(Arbitrary boolean of any name)" in a cached command/run call argument

Use UnSet to clear it.

You can check the state of them in the UI or logic functions using IsSet.

Right now, there is no way to check a value in a cached command/run call argument, because I don't know how that would work.
Animal Jul 11, 2015 @ 7:00am 
I think i worked it out, on pen and paper

If (IsSet(triggerbool)) // emulates Trigger Now;
{
If (IsSet(BehaviorA-On); //Behavior A looks for more rock to mine, Continuing Mining Loop
{
Apply(CachedcommandA;
Unset(triggerbool):
}
Else If (IsSet(BehaviorB-On); //Behavior B Initiates the return home, Breaking out of the mining loop
{
Apply(CachedcommandB);
Unset(triggerbool):
}

And let the cached commands set to "On" bools
Craig P  [developer] Jul 11, 2015 @ 7:25am 
Yeah, the logic's right.
Animal Jul 11, 2015 @ 7:27am 
That's a relief, this is the first time I've really tried to put together any kind of code in over 10 years, even if it's simplified by mimir. That and the last thing I coded in was TiBASIC, so this is completely different. Though if it were TiBASIC I'd probably have this thing doing a victory dance by now, LOL
Craig P  [developer] Jul 11, 2015 @ 7:46am 
If it's been a while, I really, really recommend using Scite or Visual Studio or MonoDevelop. You don't want a clumsy " or : to stymie you.
Animal Jul 11, 2015 @ 11:20am 
I'm getting "Name does Not exist in this context" errors when trying to use "if (IsSet(name))" in custom logic
Craig P  [developer] Jul 11, 2015 @ 11:27am 
Yeah, if it's in code, you need to pass a string:

if (IsSet("Name"))
Marziopan Jul 13, 2015 @ 10:31am 
can u suggest me a way to lock landing gears when a connector is locked and unlock them when it's unlocked plz?
Craig P  [developer] Jul 13, 2015 @ 11:20am 
@Mars: Well, that depends on whether those blocks have functioning isLocked properties. They're specified in the code, but I haven't tried them. I'll try them tonight and report back.
Craig P  [developer] Jul 13, 2015 @ 1:26pm 
@Mars: OK, check the "snippets" discussion, and make sure to use the version of Mimir I just released.
Marziopan Jul 14, 2015 @ 6:04am 
Ok thanks!
Can I use custom names for landing gears with that code? Or it affect all the landing gears?
Thanks again
Craig P  [developer] Jul 14, 2015 @ 6:13am 
That code affects all things with "Gear" in the name: "*Gear". If you want, you can name specific landing gear by removing the star, or use different key words.
< >
Showing 1-13 of 13 comments
Per page: 1530 50