Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: TheTiconTech on April 05, 2015, 04:19:54 AM

Title: Custom message artifact
Post by: TheTiconTech on April 05, 2015, 04:19:54 AM
Hi everyone!
I need some help:

How to set messages to message artifact created via "CreateUnit" command?

I cant just create it in the editor. I need it to be created in proccess via "CreateUnit".

Anyone can help?
Title: Re: Custom message artifact
Post by: planetfall on April 05, 2015, 10:33:55 AM
You can't.

However you can create a CRPL core under the message artifact which detects when it has been collected and then displays the message.


$Message:"0:Hello.;1:Yes?"

<-Artifact CONST_ISDESTROYED GetUnitAttribute if
ClearConversation
<-Message ";" split ->convo
<-convo GetListCount 0 do
<-convo I GetListElement ";" Split ->i
<-i 0 GetListElement
<-i 1 GetListElement "&colon" ":" StringReplace "&semi" ";" StringReplace "&amp" "&" StringReplace
AddConversationMessage
loop
ShowConversation
Self 0 Destroy
endif

:awake
1 OperateWhilePaused
Self CONST_TAKEMAPSPACE 0 SetUnitAttribute
Self CONST_CREATEPZ 0 SetUnitAttribute
Self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute
Self CONST_SUPPORTSDIGITALIS 0 SetUnitAttribute


Then for the script which spawns it:


"MESSAGEARTIFACT" X Y CreateUnit ->art
"CRPLCORE" X Y CreateUnit ->crpl
<-crpl "MessageArtifact.crpl" AddScriptToUnit
<-crpl "MessageArtifact.crpl" "Message" "TypeMessageHere" SetScriptVar
<-crpl "MessageArtifact.crpl" "Artifact" <-art SetScriptVar


For this example the message needs to be formatted like so:

speaker:message;speaker:message;speaker:message

Speaker must be a number, and what each number correlates to is listed here: http://knucklecracker.com/wiki/doku.php?id=crpl:docs:addconversationmessage
However since colons and semicolons separate the values, you cannot include them directly in the message. Instead, you can do &colon and &semi which the script will replace. If for some reason you want your displayed text to include "&colon" or "&semi" you can use &amp to display an ampersand.
Title: Re: Custom message artifact
Post by: TheTiconTech on April 05, 2015, 01:15:57 PM
Well... I dont understand nearly a half of what you're talking about because showing messages is incredibly easy [speaker num, message in quotes], but thanks for pickup detecting idea!
Title: Re: Custom message artifact
Post by: planetfall on April 05, 2015, 07:05:04 PM
The point of this is so that you can have one script for all artifacts, and then whatever script(s) spawn it set the message. If there is only one spawned message artifact, it makes more sense to just hard-code it.