Tuesday, December 2, 2014

Removed cholesterol from events

Note that this post might be somewhat technical for whoever never seen XML before or an SlaveMaker event.

Today I made a change to the way events are written.

There were two elements that I was not very fond of and I decided to finally eradicate them from the events.

The first element was <Resolveable> element which was needed to "decorate" some elements used to make branch in an event.

For example a piece of an event could be looked like this:

<Resolveable>
    <If Expression="true">
         <SetText>Fuck off!</SetText>
    </If>
</Resolveable>

whereas now look like this:

<If Expression="true">
     <SetText>Fuck off!</SetText>
</If>

The other element I removed (kind of it still have a use in one case) is the <Composite> which is just a collection of element. For example the <If> (again) was able a single element inside itself, so for having more than one was necessary to use the composite like this:

<If Expression="true">
    <Composite>
         <SetText>First node</SetText>
         <SetText>Second node</SetText>
    </Composite>
</If>

Now this is not needed anymore and can be written without the composite.
But I decided to leave it this node in since there's still use for it. There's in fact an element that can handle "single" elements inside itself which is the <Random> element. I said "single" since in reality the element has multiple elements as children but handle them singularly.

<Random>
   <SetText Random.Weight="1">random 1</SetText>
   <NoOp Random.Weight="98"/>
   <Composite Random.Weight="1">
       <SetText>Multiple</SetText>
       <AppendText>node</AppendText>
       <AppendText>here</AppendText>
   </Composite>
</Random>

In this case 98 times out of 100 no operation would be executed.
In 1 case out of 100 the first SetText would be executed.
In the remaining 1 out of 100 the 3 elements in the composite would be executed.

I might decide to remove it later because I'm in an ethical pickle...
But anyway for today I've written to much and probably nobody will read this anyway.

If you've been so mad to read all the way trhough and have question about event and other element that might be used, just drop a comment :)

No comments:

Post a Comment