Daraan on 27/3/2017 at 22:46
The first squirrel based script is here, nothing big. But still something new :)
(
https://www.dropbox.com/s/obhgi8k79l0bxdn/DScript0.28a.zip?dl=1) DScript v0.28a+Demo <--- Still 0.28a
(
https://github.com/Daraan/Dark-Squirrel-Scripts) Get 0.30a from GitHub
(
https://www.dropbox.com/s/4z6onzifsp785vy/DT2UndercoverWeapons.nut?dl=1) T2 Weapon replacement scripts for DImUndercover .nut file
Designed for Thief 2. Should be usable in T1/G and SS as well.
I think the ^ operator will not work in T1.
Current Scripts
DHub
DCompileTrap
DBaseTrap (Framework for all other scripts, all standard Parameters are explained there)
DRelayTrap
-DStdButton
-DHitScanTrap
DGoMissing
DImUndercover
DRay
DArmAttachment
DHudCompass
DDrunkPlayerTrap
DWatchMe
DCopyPropertyTrap
DAddScript
The standard TrapTeleporter always forces the camera to adjust to the facing of the TrapObject, therefore seamless transition via scripts was first not possible, only via S&R or later via telliameds TrapMoveRelative script.
DTeleportPlayerTrap
DTrapTeleporter
DPortal
DEditorTrap(you will find the documentation at the bottom for the .nut file as this script if wrongly used can harm your map.)
DDumpModels (extra file)
------------------
Script Changes•
DRelayTrapnow also accepts DRelayTrap[On/Off]TDest for On/Off specific Targets to more familiarity to NVRelayTrap. (Valuable Targeting parameters are either []Target or []TDest)
Script AdditionQuote:
DStdButton (DRelayTrap)
DStdButton has all the StdButton features- even TrapControlFlags work. Once will lock the Object - as well as the DRelayTrap features, so basically this can save some script markers which only wait for a Button TurnOn
Additional:
If the button is locked the joint will not activate and the Schema specified by DStdButtonLockSound will be played, by default "noluck" the wrong lockpick sound.
Quote:
DAddScriptCan be used as Root -> D[Add/Remove]ScriptFunc
Adds the Script specified by DAddScriptScript to the objects specified by DAddScriptTarget, by default &ControlDevice.
Additionally it sets the DesignNote via DAddScriptDN.. If Script parameter is not set only the DesignNote is added/changed.
On TurnOff will clear the Script 4 slot.
NOTE:
• It will try to add the Script in Slot 4. It will check if its empty or in case if it's not if the Archetype has it, else you will get an error and should use a Metaproperty.
• It is possible to only change the DesignNote with this script and so change the behavior of other scripts BUT this only works for non-squirrel scripts!
• Using Capacitor or Count for will not work for newly added DScripts. As these are created and kept clean in the Editor.
Quote:
DArmAttachmentAttaches another object to the players arm.
So when using an empty hand model you can create your own custom weapons. It can be given to any weapon-ready object together with
Inventory-> Limb Object: emptyhan or BJACHAND (Both Models included, made by Jason Otto and Soul Tear).
OR you can also add it to normal weapons to attach a Shield or Light or whatever creative stuff you come up with ;)
Parameters:
DArmAttachmentUseObject:
= 0 (Default): Will create a dummy object and give it the Shape->Model: DArmAttachmentModel
= 1 Will create a copy of a real object/archetype specified in DArmAttachmentModel. If you want to attach special effects for example.
= 2 (experimental and not really working): Same as 1 but the object will be really physical -> Real collision sounds based on the object.
= 3 (experimental little working): Same as 2 but works even better. Disadvantage: Errors in DromED, Model will pass through walls/objects.
DArmAttachmentModel: model name(0) or object Archtype (1) depending on (DArmAttachmentUseObject)
DArmAttachmentRot and DArmAttachmentPos: The model will most likely need some adjustments in position and Rotation. Both parameters take 3 arguments separated by , like this: "90,0,0" or "0.1,-0.6,-0.43". They stand for HPB Roation respectively xyz translation. But most like don't behave like you expect it. Best method how to figure out the numbers is to use it in combination with set game_mode_backup 0 (
NEVER SAVE AFTER!) and modify the DetailAttachment Link. It's trial and error.
NOTE: You will also need to do some Hierarchy changes to adjust the sound and motions. Also I would say this script is not 100% finished please give feedback.
TIP: Remember you can use multiple different melee weapons by using the cycle command. Or design them so that you can also use them from the normal inventory.
Inline Image:
https://www.dropbox.com/s/htdofcgz71wm09x/WeaponAttach.gif?raw=1Second
Quote:
DHitScanTrap (extends DRelayTrap)
(Has the DRelayTrap sending features: [On/Off]Target or [On/Off]TDest)
When activated will scan if there is an object or a wall between two objects. Imagine it as an invisible scanning laser beam. The start and end object are specified by
DHitScanTrapFrom and
DHitScanTrapTo, the script object is used as default if none is specified.
If the From object is the player the camera position is used, if the To object is the player as well then the ray will follow the center of the players view - for example to check if hes exactly facing something.
The Object that was hit will receive the message specified by DHitScanTrapHitMsg (default is "
DHitScan"). By default when any object is hit a TurnOn will be sent to CD linked objects. Of course these can be changed via DHitScanTrapTOn and DHitScanTrapTDest
Alternatively if just a special set of objects should trigger a TurnOn then these can be specified via DHitScanTrapTrigger.
THIS WAS CHANGED in 0.28a from Target to Trigger!!!NOTE: Unlike other scripts DHitScanTrapFrom and To only take single objects at the moment. I can add multiple object support as well but
NOTE2: The scanning is described as an rather expensive progress. So don't use it like 100 times per second over long distances. Best to only activate it when you need it. (That's why this is no real Trigger)
Quote:
DRayWorking with a template particle effect defined by DRaySFX, this script creates and scales particle effects between objects specified by DRayFrom and DRayTo. with the + or similar operator you can create multiple and different SFX between multiple objects at once.
For all effects only the X values and Particle Launch Infos are used!
Sending further TurnOn messages will not create additional SFX but update the already present ones.
Primarily two types are supported:
DRayScaling:
= 0 (Default): For even particle effects. This will scale up their spawn box and the particles used. A small effect with look exactly like a big one.
= 1: For "shooting" Particle effects which start at the From location. Increases particle lifetime. (Min=Max)
TIPS:
• A good template is the ParticleBeam(-3445)
• You can use this script in the editor with an appropriate DRayOn message. For example "test" (use script_test objId) or Sim (objects will be created after leaving game mode) and then delete the script object.
• By using
Particles Start Launched you can create very different and more solid effects but they will be less accurate in hitting the To object.
• You can either use an infinite repeating TurnOn from an outside Trap or DRayRepeat=-1 to constantly update your special effects in case the objects are changing positions.
• If you don't want to turn off the special effect the second method is better else I recommend the first. (Else you would need +TurnOff+TurnOff+TurnOn sequence to deactivate the script completely.
• When using launched very fast particles (like the laser in the video) the effect degenerates after a few seconds, so sending a "+TurnOff+TurnOn" with DRayOffCapacitor=50 will update the effect 50 times and then create a new one. The capacitor doesn't have to be that high but without to much performance is used to calculate the launched particles!!! (and it's a more smoother as well)
• My Demo effects are rather simple, be creative with the particle settings, share your stuff if you for example created a spiral or or or...:D
All paricles are created with DRay and the damage detection with DHitScan<video controls="controls" height="480" width="640">
<source src="http://dl.dropboxusercontent.com/s/kr3nxz9mlm965p3/Dark%20Projekt%2008.01.2017%20-%2000.15.19.09.mp4?dl=0" type="video/mp4"></source>
</video>
Quote:
DDumpModelsIncluded in the DDumpModel.nut read the instructions for more detailed information. Or in this post (
http://www.ttlg.com/forums/showthread.php?t=148055&p=2366253&viewfull=1#post2366253) here
Basically it will create the models from your obj folder and place them in the editor.
The parameters used are exactly as written here:
First= the model name of the first model you want to use; if it's a number it will start with for example the 100th model in your list.
MaxModels = will stop after for example 2000 have been created.
Screenshots=1 will automatically create screenshots in game mode while creating the models.
-----------------------------------------
Quote:
DBaseTrapThis script is the base framework for every other script, by itself it has no use but will handle the generic Parameters for the other scripts. Every Parameter explained here has to be put into the Editor->Design Note separated from the next via
;. They will work for every other script and DHub[Message]="Actions", not the DHub alone.
Normally scripts react to TurnOn and TurnOff messages. With
[ScriptName]On/Off="YourMessage" you can define other messages this script will react to.
It is possible for a script to react to more than one TurnOn/Off message. In such a case each message needs a + before them like: DRelayTrapOn="+TurnOn+FrobWorldBegin+Damage"
Squirrel Note:It is possible for a script to have another On/Off default message. You can specify this with
DefOn="CustomTurnOn" or
DefOff="YourOff" anywhere in your script class but outside of functions. Messages specified in the Design Note have priority. DWatchMe is currently the only exception which uses BeginScript instead of TurnOn
As a matter of fact this lets you simulate 3
Trap Control Flags NoOn, NoOff, Invert - NOTE: The standard Trap Control Flags set with the object property have no effect on DScripts.
You can use
[ScriptName]On="TurnOff";[ScriptName]Off="TurnOn" to simulate
Invert;
[ScriptName]On="Null" can be used to simulate
NoOn and
[ScriptName]Off="Null" can be used to simulate
NoOff.
Remember that if you specify
[ScriptName]On="TurnOff" without specifying
[ScriptName]Off, then TurnOff will perform the On as well as the Off action.
[ScriptName]Count
Use this parameter to specify the maximum number of times that the script will work. You can use [ScriptName]Count=1 to emulate the Once Trap Control Flag. The default is 0 (infinite).
Both TurnOn and TurnOff are counted by default. You can use [ScriptName]CountOnly=1 to count only TurnOn, and [ScriptName]CountOnly=2 to count only TurnOff - the respectively other message will still have their full effect even if the Count is full. Sending the trap a ResetCount message will reset the counter.
[ScriptName][On/Off]Capacitor
Use this parameter to specify the number of times that a trap will need to receive its triggering message before it activates. For example, an NVRelayTrap with NVRelayTrapCapacitor=3 will only relay every third message, while one with NVRelayTrapOnCapacitor=4; NVRelayTrapOffCapacitor=2 will relay every second TurnOff message but only every fourth TurnOn message. The default is 1.
[ScriptName][On/Off]CapacitorFalloff can be used to specify the time, in [seconds], that it takes for the trap to "lose charge", and the activation count to go back down by one activation.
NOTE 1: Count and Capacitor data are refreshed on script_reload and exiting game_mode. Therefore I suggest that you insert the script_reload command into your GameMode.cmd
NOTE 2: All Capacitor parameters don't interfere with each other. For example setting Capacitor=3 and OnCapacitor=2 and then receiving TurnOff,TurnOff,TurnOn,TurnOn will relay both TurnOn messages as the first TurnOn is the 3rd message and the 2nd is the 2nd TurnOn.
Same goes for CapacitorFalloff it won't decrease an OnCapacitor only OnCapacitorFalloff will do.
---
[ScriptName]Delay
Setting this to a value greater 0 will postpone the action performed by this script by the specified number in
seconds. [ScriptName]Delay=0.5 for example would delay the action by 500ms.
By setting [ScriptName]ExlusiveDelay=1 the script will abort the still being delayed action and will start the Delay at 0 again. This is for example useful if you want a script to react to Water Arrows or entering a Room/OBB where due to the engine multiple On messages are sent in a very short time.
[ScriptName]Repeat
If you want a script to repeat it's actions multiple times you can set this parameter. By default it is 0 for none. The time between repeats is specified with [ScriptName]Delay.
Infinite repeats are declared via [ScriptName]Repeat=-1 and will be stopped by the corresponding other message. A infinite repeating TurnOn will be stopped by a TurnOff. This single TurnOff will only stop the repeat and will
not perform the DoOff action of the script. Only a second TurnOff will trigger it.
[ScriptName]FailChance
A chance (from 1 to 100 or -100 to -1) that the specific script will not activate. If you define a negative value Capacitor and Counts will still be increased first and then tested if the script will fail or not.
If a script is looking for an object parameter for example [ScriptName]Target you can use the following expressions. $QVar can be used for all Parameters as it represents a number for example DRelayTrapRepeat="$MyQVar"
Code:
[me] the object itself
[source] the object that sent the triggering message
&LinkFlavor all linked objects with the specific link.
*Archetype/MetaProp all concrete objects directly descending from the given Archetype
@Archetype/MetaProp all concrete objects given Archetype and all of its descendants
^Archetype/MetaProp/Name finds the closest object.
$QVar will sent to the object with the number stored in the Quest Variable QVar
//Something NEW: little but powerful
+Everything Single objects and combinations of the other types.
+-Everything Remove a previously added subset.
When using the + operator you need a # before pure object/archetype numbers, also for example "+#42+#-17"
Example:
•Target="+[me]+&~ControlDevice+@M-DoesPatrol+coolguy+#42"
This will give back the object itself, all ~ControlDevice'd linked objects, every object with the MetaProperty M-DoesPatrol, the object named coolguy and the object with the number 42. IMPORTANT: if you want to address a pure object number you need # before it. (Only needed in combination with +)
•Target="+@guard+-@M-FrontGateGuard+-@M-TopFloorGuard"
Note: Even if only one object is needed like for DCopyPropertySource="&LinkFlavour" you will only get the object with the highest LinkID (needs confirmation) that you will get only one is for sure.
Design Note ExamplesDTeleportPlayerTrapOn="TurnOff"
DTrapTeleporterOn="FireStimStimulus"
DRelayTrapRepeat="$MyQVar"
Note/TipFrom my testings Scripts from different .nut are shared, so you could also use extend DBaseTrap in your files without having to creating a new class yourself.
Quote:
DHub(not a DBaseTrap script)
will by default send a TurnOn at ControlDeviced linked objects when it receives a valid message. Valid messages are declared in the DesignNote like this: DHub[Message]="Parameter1=Value1;Parameter2=Value2". Even if you want to use the default options a minimal DHub[Message]="==" is necessary! The + operator does not work here.
Multiple actions can be declared for the same Message via DHub[Message]2="Parameter1=Value1;.... The used numbers must be consecutive! If there is a gap all above numbers will be skipped. There is no maximum to different actions a Message can have.
Parameters are basically identically to the ones by DBaseTrap or DRelayTrap beside [T]On/Off.
NOTE:!Parameters require no prefix. String values may not have " " around them!!! And I don't recommend blank spaces anywhere inside the "Parameter=Value;P2=V2" declaration, only if you want to address an object like Target=@false label
The valid parameters - all operators like +,@,$... will work here
Code:
Relay What message(s) should be sent. Like for DRelayTrap there is stim support like [3.7]FireStim.
Target To which object(s)
Delay will delay the message and also defines the time between repeats.
ExclusiveDelay When set to =1 will abort messages from this action which are still waiting to be sent.
Repeat how often should the action be repeated. Repeat=-1 for infinitely.
All Infinite repeats can be stop via a StopRepeat. A single action (repeat must not be infinite) via [Message+number]StopRepeat.
Count The maximum number of times a action will be executed. Default =0 infinitely.
All counts can be reset via a ResetCount message. Single action counts like above with via [Message+number]ResetCount.
Capacitor The number of times this action will need to receive its triggering before executing. Default = 1 everytime.
CapacitorFalloff The time in seconds after the Capacitor will go down by 1. Default =0
FailChance A chance (from 1 to 100 or -100 to -1) that this action be executed. If the number is negative Capacitor and Counts will still be increased first and then tested if the script will fail or not.
Default Parameter:
By setting DHub[Parameter]="Value". This Parameter will be default for all actions if not specified otherwise.
As an example and as script default DHubRelay="TurnOn";DHubTarget="&ControlDevice".
Design Note exampleInline Image:
https://www.dropbox.com/s/nzwt7tzhxgremuo/DHubExample.jpg?raw=1Quote:
DHudCompassUpon receiving FrobInvEnd will clone the current selected object and attach it slightly below the players camera and keep its facing always to north.
By default there is no TurnOff as it is TurnedOff via toggling.
Engine Features -> Frob Info > Inv Action: Script must be set.I suggest scaling down the object to 10-50%.
Inline Image:
https://www.dropbox.com/s/dsp0xu1lc367vvs/DHudCompass.gif?raw=1Quote:
DCompileTrapOn TurnOn tries to compile the Editor Comments.
This script lets you write your own squirrel commands inside the editor.
It uses Editor Comment because the Squirrel line/command end
; also indicates a new Parameter in the Design Note which do interfere, also you are able to use newlines much easier. But the newlines(made by enter) will be translated to \n and to not destroy your code you need to comment these \n out with a /* at the end of the line and */ at the start of the next
Editor Comment example:Code:
ActReact.Stimulate(Object.Named("player"),"BashStim",20);/* now comes a new line
*/DarkUI.TextMessage("String made by DCompileTrap");/*
*/DarkGame.KillPlayer()
Squirrel changes: (See also end of this post)--DGetParam removed the single parameter as now everything undergoes a string check handled by DCheckString and returns a single obj,string unless adv=1 is set, then an array is returned.
--All DoOn,DoOff functions will now take the DesignNote as a parameter to save internal extra calls.
--Removed most of the basic functions from the DBaseTrap so you can access them in other .nut files without using extend DBaseTrap.
-------------------------------------------------------------------------
Quote:
DRelayTrapCan be used as Root -> DSendMessage; DRelayMessages
A relay with all the DBaseTrap features. On TurnOn it will relay the message specified with DRelayTrapTOn. Respectively the on TurnOff to be sent messages can be specified with DRelayTrapTOff. By default these are TurnOn and TurnOff.
With the + operator you can define multiple On, TOn, Off and TOff messages.
With DRelayTrap[On/Off]Target (NEW: Also [On/Off]TDest works as an alternative) you can specify where to sent the message(s) to. Default are ControlDevice linked objects. If DRelayTrap
OnTarget is specified then it will take priority over DRelayTrapTarget.
As a TOn, TOff message you can also send a Stim to do this, first enter the intensity surrounded by square brackets, followed by the stim name. For example: [ScriptName]TOn="[5.00]WaterStim".
Design Note exampleNVRelayTrapOn="+TurnOn+BashStimStimulus";NVRelayTrapTOn="+TurnOn+[5]FireStim";NVRelayTrapOnTarget="+player+^ZombieTypes"
What will happen:
On TurnOn or when bashed it will send a TurnOn and a FireStim with intensity 5 to the player and the closest Zombie.(relative to the object with the script)
As nothing else is specified on TurnOff will send a TurnOff to all ControlDevice linked objects.
Code:
DDrunkPlayerTrapOn TurnOn makes you drunk a TurnOff sober.
Multiple Ons from the same source will reset the timer and will do a FadeIn again. Multiple sources do stack.
Optional parameters:
DDrunkPlayerTrapStrength regulates the strength basically every number can be used I would suggest something between 0 and 2 default=1
DDrunkPlayerTrapInterval a second regulator how often the effect is applied. With a lower interval higher strength becomes more acceptable. default[seconds]=0.2
DDrunkPlayerTrapLength How long the effect will last in seconds. Use 0 for until TurnOff is received default[seconds]=0
DDrunkPlayerTrapFadeIn Fades in the effect over the given time at the end the full strength is used. default[seconds]=0
DDrunkPlayerTrapFadeOut
Only works if Length is set! Will gradually make the effect weaker over the last given seconds. default[seconds]=0
DDrunkPlayerTrapMode The effect is made up by 1) shaking the camera and 2) Pushing the player.(left/right/forward). default=3
By setting Mode to 1 or 2 you can use one effect only. Especially for Mode=2 higher Strength values can be used.
Check out the demo how this can be used as a potion.NOTE: v0.22: it's Savegame compatible now.
I think you can also create some interesting effects with an early FadeOut and Repeats.
Quote:
DCopyPropertyTrap
Target default: &ScriptParams
Source default: [me]
Similar to S&R->SetProperty but can set multiple properties on multiple objects at the same time.
Upon receiving TurnOn copies the properties specified by DCopyPropertyTrapProperty form the object DCopyPropertyTrapSource(default is [me]) to the objects specified through DCopyPropertyTrapTarget if not setScriptParams linked objects will receive the propertie(s) by default.
Multiple properties can be copied with the + operator.
You use the script object as a sender or receiver.
Design Note example:DCopyPropertyTrapProperty=""+PhysControl+RenderAlpha";DCopyPropertyTrapSource="&Owns";DCopyPropertyTrapTarget="[me]"
This will copy the Physics->Controls and Renderer->Transparency(Alpha) property from the object linked with an Owns linked to the object itself.
Quote:
DWatchMeBy default when this object is created or at game start (BeginScript) creates AIWatchObj Links from all Human(-14) to this object.
Alternatively an alternate
DWatchMeOn message can be used, as well as
DWatchMeTarget to specify another object, archetype or metaproperty.(see notes below)
•Further (if set)
copies!! the
AI->Utility->Watch links default property of the archetype (or the closest ancestors with this property) and sets the
Step 1 - Argument 1 to the Object ID of this object.
•Alternatively if no ancestor has this property the property of the script object will be used and NO arguments will be changed. (So it will behave like the normal T1/PublicScripts WatchMe or NVWatchMeTrap scripts).
On TurnOff will remove any(!) AIWatchObj links to this object. You maybe want to set DWatchMeOff="Null".
------------------------------
Usefullness:If you have multiple objects in your map and want that AIs perform simple(?) actions with each of them under certain conditions.
For example:
You can use it to let guards relight every extinguished torches on their patrol path -> see Demo.
Initially it was designed to be used with DPortal do force an alerted AI to follow the player through portals. Still not optimal but the basics are there.
Tip:If you use a custom On command, multiple links could be created so you may want to set the Watch->"Kill like links" flag in that situation.
Design Note Examples:DWatchMeOn="WaterStimStimulus";DWatchMeTarget="@guard";DWatchMeFailChance=60
DWatchMeOn="TurnOn";DWatchMeTarget=42
DWatchMeTarget=ValidObjectName
DWatchMeTarget=*swordsman
--------------------------------------------------------
Quote:
DTPBaseBase script for the other 3 scripts. Has by itself no use.
•If a patrolling AI is teleported it will reassume its patrol after teleportation from the now closest Patrol Point.
•Contains the DTeleportation(who,where) function which teleports a given object to absolute world coordinates.
Quote:
DTeleportPlayerTrap•Upon receiving TurnOn moves the player by x,y,z values specified in the Design Note via
DTpX=;DTpY=;DTpZ=. Use for 100% Seamless teleportation.
•If no parameter is set or all are 0 then the player gets teleported to the location of this object instead.
Design Note Example:DTpX=-3.5;DTpZ=10
Quote:
DTrapTeleporter
Target default: &Control DeviceUpon receiving TurnOn teleports a ControlDevice linked object to this object and keeps the original rotation of the object.
Further by default currently non-moving or non-AI objects will be static at the position of the TrapTeleporter and not affected by gravity until their physics are enabled again - for example by touching them.
By setting
DTeleportStatic=0 in the Editor->Design Note they will be affected by gravity after teleportation. Does nothing if Controls->Location is set.
Design Note Example:DTeleportStatic=0
DTrapTeleporterTarget=@Zombie types
Quote:
DPortalDefOn ="PhysEnter"
Default Target = Entering Object. (not [source]!)
Teleports
any entering object (PhysEnter).
Either by x,y,z values specified in the Design Note via
DTpX=;DTpY=;DTpZ= or to object linked with ScriptParams. If a value in the Design Note is specified the first option takes priority!
Unlike DTeleportPlayerTrap this script takes the little offset between the player and the portal center into account, which enables a 100% seamless transition - necessary if you want to trick the player.
Design Note Example:DTpX=-3.5;DTpZ=10
DPortalTarget="+player+#88+@M-MySpecialAIs"
TipIf you use the ScriptParams link and want a seamless transition, place the destination object ~3 units above the ground
---------------------------------------------------
Quote:
DScript 0.28a Squirrel FeaturesThese features/functions specified here are globally available to who has the DScript.nut file and are not bind to the DBaseTrap.
DGetParam("FullParameterName",DefaultValue, Table ,adv=0)Returns the parameter in the DesignNote if none is present the DefaultValue instead. The 3rd parameter is where you actually look most of the time you will pass the Design Note (userparams()) on here but also check in every other table-like structure like classes.
if a value is found or else the default it will be analyzed by:
DCheckString(r,adv)This function analyzed the given string r and performs the operator checks as listed in DBaseScript. @,&,[me],+ ...
Each found object will be stored in an array. If adv = true the whole array will be returned and can be used for foreach (t in array){ ... }. Else if adv=0/false only a single value will be returned.
DGetStringParam("FullParameterName",DefaultValue, String ,adv=0)Identically to DGetParam but that this function takes strings which are formatted like this: "ParameterName=Value;Key=Value2". DCheckString is then called as well.
DGetAllDescendants(Archetype,array)Returns all concrete descendants of an archetype and all other inherited archtypes in an array. The function must be given an array to work with all found objects will be added to that array.
DCountCapaCheck(Script Name, Design Note, true/false for On/Off) and DCapacitorCheck
These handle partly the Count and Capacitor parameters for the DBaseTrap and then call the DoOn/Off functions. As they are global functions I noted them here but they will not work as standalone.
DArrayToString(Array , Seperator ="+") converts an array to a string with the character defined by Seperator between them, default +. The reverse to string split.
DSendMessage(Target, Message) (need extends DRelayTrap)
Will send a single
Message to a single
Target and check if the
Message should be a Stim. If so it will stimulate the Target.
DRelayMessages("On" or "Off", DesignNote) (need extends DRelayTrap)
Will relay the Message
s in [ScriptName]T[On/Off] to the objects [ScriptName][On/Off]TDest via DSendMessage.
--------------
Quote:
DSetTimerData(name, delay,...[data you want to attach]) returns timer_handle
DSetTimerDataTo(To,name,delay,...) same as above but sent to To instead of self.
DGetTimerData(msgdata,KeyValue=false) returns an Array with your data.
The functions start a timer with multiple data attachments which can be returned later in an array out of the message().data.
This Data is save game compatible!
--------------
But now let me explain why these functions are important/usefull:
If there time gap between 2 actions, there is always the problem how to safely carry over data. The (human) player could save and reload the game in the meantime and all non persistent data will be whipped as new script instances are recreated (that's how I understood it).
The relevant persistent data are script data set with SetData(k,v), QVars and timers.
I don't know it but I think NV came up with something similar so I take an NVRelayTrap as an example: which inverts the message and sends it twice back to the sender (with a delay).
So now we got two objects sending a TurnOn and TurnOff to the Trap and here's the problem a) after the delay how to know which object sent the message? b) What was the message again? and c) how to know if it's first message and needs to be send again?
We would need to save three values. But SetOneShotTimer only has one data slot. The second message would override the first SetData or QVar. Well you could store multiple ScriptData with a prefix and save that prefix in the timer data slot, but I think memory wise that's not the best solution, also it would increase very fast if you need to transfer even more data.
Btw: Squirrel somehow lacks the SetTimedMessage(2) function why?.
--------------
Data can be stored and retrieved in a fixed order (KeyValue=false) or in a not sorted Key=Value manner, for the later see below. As an example for the sorted manner if you know the first data is always the source and the second the are repeats left. Returned Array will be[source Obj ID, Repeats left]
And you can use array[0],array[1] to grab your data.
If there are other data you want to store but for example some are optional or whatever you can store them via key=value,key2=value2,...
now if you use KeyValue=true the array will look like this [key,value,key2,value2] and you can search and find your values like this:
Code:
local array=DGetTimerData(message().data,true)
local key = array.find(param);
loval value =0
if (key!=null)
{value =array[key+1]}
Take a look at the DDrunkPlayerTrap how I made use of that.
-----------------------------------
Installation##NewDark+Squirrel Installation##
1. Be sure to have at least (
http://www.ttlg.com/forums/showthread.php?t=147689) NewDark 1.25
2. Beside new_dark.zip and editor.zip inside the NewDark1.25.zip open contrib.zip and export squirrel.osm into your main folder.
3. If not present create a folder named
sq_scripts in your main folder.
##Script Installation##
1. Download
2. Extract the contents of the .zip directly into your main folder or the DScript.nut into your sq_scripts folder
3. In the editor script_load squirrel