Renamed to elm-messenger/messenger-core. That is where the repository lives now. It has not been published as a package under the new name.
Versions published as linsyking/messenger-core still install under that name. 34 versions of 52 come from the new location (see their notes). 7 versions could not be recovered and cannot be installed.
Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: Software Heritage has not archived the repo; no fork with tag 16.0.0 found (17 same-name repos checked); no cached copy. Use another version.
A component is an object that you may put in your layers.
These are components that you users can create with custom basedata.
Basedata is the data that components with the same type can share.
For example, you may want a game component to have some common properties like position, velocity, etc.
In this case, your basedata would be a record with these properties.
ConcreteUserComponent
Not very likely to be used. The messenger template will handle this for you automatically.
Generate abstract user component from concrete component.
Update a list of abstract user components.
Update a list of abstract user components with block indicator.
It block is True, this function will not update anything.
Update a list of abstract user components with targeted msgs.
Generate render list for one list of components.
Useful when there are several component lists.
The output should be used as the input of viewComponentsRenderList.
View the render list of components.
Useful when there are several component lists.
The input should be generated by several genComponentsRenderList.
View one list of abstract components.
Used when there is only one list of components
Component init type sugar.
Receives the environment and the initializing message (from which you can extract the parameters used to initialize the object, for example position), and returns a tuple of (Data, BaseData).
Component update type sugar
Determines the behaviour when a UserEvent is sent to the component. This could include, but not limited to, a mouse click, a keyboard press, or most commonly a time tick (which means a specific amount of time has passed, see the manual)
Receives the environment env, the UserEvent evnt, the currect data and basedata ,and returns a structure in ((Data,BaseData),List Msg, (Env, Bool)).
Note: The last bool determines if the message would be blocked from the next component. If it is set to be True, then all the components behind it will not receive this UserEvent. This is useful when you want the action of the player only influence the front component, but not the conponents behind them.
Note: data is somehow private, but baseData is public. More precisely, baseData can be accessed safely at layer level since it is the same for every component in the layer.
Component updaterec type sugar
Determines the behaviour when other components, layers or scene sends messages to the component. For example, a knife component may send a message to the monster component to decrease its blood.
Receives the environment env, the component messages (defined in ComponentBase.elm), the currect data and basedata ,and returns a structure in ((Data,BaseData),List Msg, Env).
Component view type sugar
Renders the component. If you want to render multiple things, you should use Canvas.group to assemble them into one renderable. The second entry of the returning tuple is the "z-index" of the component. For example, if you want to put something important to the toppest layer of the window (Like the mouse cursor), you can set it to a very high value(like 1000).
Receives environment, data, and basedata.
Component matcher type sugar The function that is used to judge if this component is the target of a incoming component msg (sent by OtherTar). It will return true if the incoming componentMatcher matches this component.
It receives data, basedata, and the componentMatcher value of the incoming message.
Here is an example of it:
matcher : ComponentMatcher Data BaseData ComponentTarget
matcher data basedata tar =
tar == Type basedata.ty || tar == Id basedata.idWhere the matcher will return true if the id or the name matches the incoming message.
Component storage type sugar
Level component storage type sugar
This is a type sugar for dividing a long update function into smaller pieces to enhance code quality. It receives a ((Data,BaseData),List Msg, (Env, Bool)) and returns a tuple of same kind. Here is a piece of sample code:
judgeMsg : UpdateMiddleStep SceneCommonData Data UserData SceneMsg ComponentTarget ComponentMsg BaseData
judgeMsg ( ( data, basedata ), msg, ( env, bool ) ) =
( ( data, basedata ), msg, ( env, False ) )After defining this, using this in Update is as simple a a cup of tea.
case evnt of
Tick t ->
( ( data, basedata ), [], ( env, False ) )
|> judgeMsgNote: you may add extra argument to your function like this:
myFunc : Int -> UpdateMiddleStep
and call like this:
( ( data, basedata ), [], ( env, False ) ) |> myFunc 1
This is a type sugar for dividing a long updateRec function into smaller pieces to enhance code quality. It receives a ((Data,BaseData),List Msg, Env) and returns a tuple of same kind. It is really similar to UpdateMiddleStep, see the examples there.
Abstract component