TTLG|Thief|Bioshock|System Shock|Deus Ex|Mobile
Page 1 of 2 12 LastLast
Results 1 to 25 of 46

Thread: DScript -A Squirrel script v0.28b

  1. #1
    Member
    Registered: Jan 2012
    Location: Gèrmany

    DScript -A Squirrel script v0.28b

    The first squirrel based script is here, nothing big. But still something new

    DScript v0.28a+Demo <--- Still 0.28a
    Download 0.28B Script .nut file only (this link will always point to the most recent file)
    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
    DRelayTrap
    now 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 Addition

    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.
    DAddScript
    Can 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.
    DArmAttachment

    Attaches 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.



    Second
    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)
    DRay
    Working 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...
    All paricles are created with DRay and the damage detection with DHitScan




    DDumpModels
    Included in the DDumpModel.nut read the instructions for more detailed information. Or in this post 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.
    -----------------------------------------
    DBaseTrap
    This 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 Examples
    DTeleportPlayerTrapOn="TurnOff"
    DTrapTeleporterOn="FireStimStimulus"
    DRelayTrapRepeat="$MyQVar"

    Note/Tip
    From 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.
    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 example
    DHudCompass
    Upon 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%.
    DCompileTrap
    On 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.


    -------------------------------------------------------------------------

    DRelayTrap
    Can 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 DRelayTrapOnTarget 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 example
    NVRelayTrapOn="+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:
    DDrunkPlayerTrap
    On 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.

    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.


    DWatchMe
    By 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

    --------------------------------------------------------
    DTPBase
    Base 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.
    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
    DTrapTeleporter

    Target default: &Control Device


    Upon 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
    DPortal

    DefOn ="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"
    Tip
    If you use the ScriptParams link and want a seamless transition, place the destination object ~3 units above the ground
    ---------------------------------------------------


    DScript 0.28a Squirrel Features
    These 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 Messages in [ScriptName]T[On/Off] to the objects [ScriptName][On/Off]TDest via DSendMessage.

    --------------
    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 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
    Last edited by Daraan; 12th Sep 2017 at 18:19.

  2. #2
    Desperately dodgy geezer
    Registered: Nov 2001
    Location: The Wailing Keep
    Holy crap, hardly a week since NewDark 1.25 and we already have a released SqScript module. Well done, thanks Daraan!

  3. #3
    Member
    Registered: Sep 1999
    Location: Portland, OR
    Thank you!!

  4. #4
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Can you please show a sample design note for each. It is not clear if you intend, say, x=value or DTeleportPlayerTrapX=value, when you say x,y,z values specified in the Design Note. I would recommend the latter, as another script on the object may be looking for an x=.

  5. #5
    Dóttirin klæðist oft móður möttli
    Registered: Apr 2015
    Did you test the script in Thief2.exe as well?

  6. #6
    Member
    Registered: Jan 2012
    Location: Gèrmany
    Quote Originally Posted by LarryG View Post
    Can you please show a sample design note for each. It is not clear if you intend, say, x=value or DTeleportPlayerTrapX=value, when you say x,y,z values specified in the Design Note. I would recommend the latter, as another script on the object may be looking for an x=.
    Yah I see the point. As I have to catch (optional)parameters currently via try..catch calls and these take a lot of space I made DPortal and DTeleportPlayerTrap use the same function and parameters for that.

    Not sure if there is a better way or if userparams().[InsertScriptNameHere]x is somehow possible.????? Think I will use DTpx,DTpy,DTpz as common values for now instead.

    You have to wait for 0.16 real quick


    Quote Originally Posted by Unna Oertdottir View Post
    Did you test the script in Thief2.exe as well?
    I only tested it with T2. But the functions used are generic so should work in System Shock too.
    Only concern that just came up. Is the player object in SS named player too?
    Last edited by Daraan; 28th Mar 2017 at 12:58.

  7. #7
    Zombified
    Registered: Sep 2004
    yes.

  8. #8
    Member
    Registered: Nov 2001
    Location: uk
    Quote Originally Posted by Daraan View Post
    As I have to catch (optional)parameters currently via try..catch
    Not sure if there is a better way or if userparams().[InsertScriptNameHere]x is somehow possible.????? Think I will use DTpx,DTpy,DTpz as common values for now instead.
    Firstly, sorry for being lazy and not bothering either to properly look at what you're doing, try anything myself or even find out whether I have a working dromed install to try it on...

    indexes into tables are generally strings and userparams().something is the same as userparams()["something"]
    You can concatenate strings with + so you can do userparams()["something"+"x"]

    I tend to use table.thing unless I'm iterating through part of a table which has keys that are partly numeric
    real world shaped example from my day job sortafing
    Code:
    local tDevices = ICR_GetPGMData(301,1);
    for (local nCount = 1; nCount <8; nCount++)
    {
        local thisDevice = tDevices["KP"+nCount];
        // do something to this device
    }
    There are two things you can do to not try/catch an index that might not be there, you can use in to ask it if it's there or you can override the function squirrel calls when something isn't there using _get
    Which is easier/better/faster depends on what you want to do when it's not there and why it might not be there.

    Skim reading your .nut file in is probably what you want

    something like
    Code:
    function DParameterCheck()
    {
    	local x = 0;
    	local y = 0;
    	local z = 0;
    
            local params = userparams();
            if ("DTpX" in params)
            {
                x = params.DTpX;
            }
            if ("DTpY" in params)
            {
                y = params.DTpY;
            }
            if ("DTpZ" in params)
            {
                z = params.DTpZ;
            }

  9. #9
    Member
    Registered: Jan 2012
    Location: Gèrmany
    Thank you caffe. Great info.
    Edit: Did I get this right _get would also work and would be faster than in checks?


    v0.17
    Added another base script DBaseTrap
    with basic parallels to NV's base script. Damn I wish I would have the source files^^ Is there any chance? Please
    Other scripts have been updated to work like this.

    DBaseTrap
    Handles custom [ScriptName]On/Off parameters specified in the Design Note and calls the DoOn/DoOff actions of the specific script.
    If no parameter is set the scripts normally respond to TurnOn and TurnOff if not specified otherwise like in DWatchMe.
    Squirrel Note: If you instead want another default activation message you can specify this with DefOn="CustomTurnOn" or DefOff="TurnOn" anywhere in your script class but outside of functions. Again messages specified in the Design Note have priority.

    As a matter of fact this lets you simulate the 3 Trap Control Flags NoOn, NoOff, Invert

    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.


    Design Note Examples
    DTeleportPlayerTrapOn="TurnOff"
    DTrapTeleporterOn="FireStimStimulus"

    Note/Tip
    From my testings Scripts from different .nut are shared, so you could also use extend DBaseTrap in your files without creating a new class.
    Last edited by Daraan; 29th Mar 2017 at 03:52.

  10. #10
    Member
    Registered: Nov 2001
    Location: uk
    I'll stick it in your other thread so as not to clutter this one up with squirrel stuff

  11. #11
    Member
    Registered: Mar 2001
    Location: Ireland
    Quote Originally Posted by Daraan View Post
    with basic parallels to NV's base script. Damn I wish I would have the source files^^ Is there any chance? Please
    I was thinking that would be very useful for people trying to set up a Squirrel base. I should look into it.

  12. #12
    Member
    Registered: Jan 2012
    Location: Gèrmany
    Coming in the not yet finished 0.18.
    Tidied up code

    and as such a script doesn't exist yet. (expect setproperty)

    DCopyPropertyTrap

    Similar to S&R->SetProperty but allows to copy to multiple objects as well.

    Upon receiving TurnOn copies the property specified by DCopyPropertyTrapProperty form the object DCopyPropertyTrapSource to either this object or if ScriptParams links exist to these! objects.
    Thus making the object with this script a sender or receiver.
    ---------------

    Especially @NV:
    I was a bit surprised, that the @-symbol worked as I know it from NVscripts
    and so the question came up which other of the symbols would/could work out of the box? (I'm not at home currently so I can't try)
    Code:
    [me] I guess these two don't.
    [source]
    ^Marker
    ^<20:Marker
    ^{20:Marker
    &ControlDevice
    &?ControlDevice
    &Weighted
    *Marker
    @Marker
    <20:Marker
    {20:Marker
    For the start DCopyPropertyTrapTarget is/would be hardcoded to these two options.

    --------
    EDIT: A parameter returning base function is now done as well.
    Will adjust the other scripts and then upload an alpha version. (As atm I can't test it myself)
    EDIT2: And it's up.
    Last edited by Daraan; 31st Mar 2017 at 20:06.

  13. #13
    Zombified
    Registered: Sep 2004
    Quote Originally Posted by Daraan View Post
    DCopyPropertyTrap
    I think I'm going to like this one. also, can I make a request please? I have been craving a script that would make the screen wobbly after consuming an item (poisoned, alcoholic etc) for many years now.

  14. #14
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    A MakePlayerDrunk script?

  15. #15
    Zombified
    Registered: Sep 2004
    yeah.

  16. #16
    Member
    Registered: Mar 2001
    Location: Ireland
    Quote Originally Posted by Daraan View Post
    I was a bit surprised, that the @-symbol worked as I know it from NVscripts
    and so the question came up which other of the symbols would/could work out of the box? (I'm not at home currently so I can't try)
    @Archetype was a notation that Thief already used (in conversations and other pseudoscripts), which is probably why it works there.
    (I'm not sure about * off the top of my head, that might have done something in pseuoscripts too?)
    All of those others are notations invented by me, so I doubt that they will work.

  17. #17
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Me, I'd like a multiple message relay trap script. Instead of being ostensibly on/off focused like NVRelayTrap, I would like a general purpose message relay trap that handles as many different messages as possible. It should support all the NVRelayTrap whizbangs (delay, once, repeat, and so on), just for more than two messages at a time. For a relay trap, which doesn't actually do anything other than pass messages (after suitable massaging as instructed), there is no real relevance to ON and OFF, so why limit the relay to just two messages, why not make it a hub instead for many messages? As long as you can assign TDest to each independently, you can have a powerhouse of a relay. And that can save script slots if you can have one script do 8 or 10 or more relays.

  18. #18
    Member
    Registered: Aug 2004
    Location: netherlands
    Quote Originally Posted by LarryG View Post
    A MakePlayerDrunk script?
    didn't NV release a (demo?)mission that had that effect???
    it was a mission that also had a big hand pointing directions in ,if I recall corrrect, sewers or tunnels

  19. #19
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    He did have something related in his demo, but IIRC it wasn't a true drunken player. He patched together something that almost felt like your controls weren't working, but not really. Personally, I think the only way that it can be done believably is for the player to go out to a pub at the right point in the mission, then come back at closing time and resume play. Not something that you can script easily in squirrel.

  20. #20
    Member
    Registered: Jan 2012
    Location: Gèrmany
    So first things first 0.19
    Old scripts now really work. Sorry.
    DGetParam got upgraded and beside that it really really works now can check for the following string parameters: (adv=1)
    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.
    
    //Something NEW: little but powerful
    +Everything         Single objects and combinations of the other types.
        Example: 
        To="+[me]+&~ControlDevice+@M-DoesPatrol+coolguy"
        This will give back the object itself, all ~ControlDevice'd linked objects, every object with the MetaProperty M-DoesPatrol and the object named coolguy.
    Additionally DGetParam now takes 2 optional parameters adv, single.
    adv=1 is used to return objects and will perform the above checks. (objects will be returned in an array to be used with 'for obj in array')
    adv=1,single=1 works only in this combination! Will return a single, not arrayed object. For example Source="&~ControlDevice" where exactly one object is needed and expected.





    A MakePlayerDrunk script?
    I crawled for ages though the SS source files to get an idea how NVShakePlayer/ShakeYourBooty was scripted.... found nothing and no dang idea.
    but yah here you go:

    Code:
    DDrunkPlayerTrap
    On 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.
    I think this script needs much fine tuning to be cool, as you can even simulate an earthquake, feel free to experiment in the .nut file with the numbers as well. (Properties and Physics line).
    Long Parameter names suck



    -----------------------
    EDIT:

    v0.20c



    All scripts now support
    [ScriptName]Count
    [ScriptName]CountOnly
    [ScriptName][On/Off]Capacitor
    [ScriptName][On/Off]CapacitorFalloff


    Copy pasting NV's description:
    [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.

    -------
    v0.20d
    •New Parameter: $QuestVariable is now a valid.
    --DGetParam lost the single parameter as now everything undergoes a string check handled by DCheckString
    •DCopyPropertyTrap supports now targeting AND allows to copy multiple like for example DCopyPropertyTrapProperty="+PhysControl+RenderAlpha"
    •DPortal now works with DPortalTarget and Non -PhysEnter messages. For example you can use DPortalOn="PhysExit"; (leave target blank in this case!)
    Last edited by Daraan; 7th Apr 2017 at 13:53.

  21. #21
    Member
    Registered: Jan 2012
    Location: Gèrmany
    So one of the last updates v0.21

    but it brings lots of functionality, also made it more clear in the first post which global functions you can use in your .nut files.

    -----------v0.21--------------
    Parameter additions
    •Scripts now accept multiple On/Off messages via the + operator.
    •$MyQVar now a valid parameter which will check for the saved data in the Quest Variable MyQVar
    •Added [ScriptName]FailChance. Chance to let a script fail. Can be positive or negative see DBaseTrap.
    Script additions
    •Added a basic DRelayTrap so you can make use of multiple TurnOns and sent multiple messages with the + operator. Stims can be sent as well. See DRelayTrap for more info.

    Script changes
    •DCopyPropertyTrap supports now targeting AND:
    --Allows to copy multiple properties with the + operator like: Property="+PhysControl+RenderAlpha"
    •DWatchMe accepts TurnOff to remove any!! AiWatchObj links to this object.
    •DPortal now works with DPortalTarget and Non -PhysEnter messages. For example you can use DPortalOn="PhysExit"; (leave target blank in this case!)
    •When using the + operator with pure object numbers they need a # before them from now on like: +#42+player+#225 else they will be treated as sting "42" which can't point to an object, expect an object is really named "42"


    Squirrel changes:

    --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.

    DRelayTrap
    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 you can specify where to sent the message(s). Default are ControlDeviced linked objects. If DRelayTrapOnTarget is specified then that 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".

    There is no Repeat or Delay option.

    Design Note example
    NVRelayTrapOn="+TurnOn+BashStim";NVRelayTrapTOn="+TurnOn+[5]FireStim";NVRelayTrapOnTarget="+player+^ZombieTypes"

    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.
    That should be pretty close to Larry's Hub.
    Last edited by Daraan; 8th Apr 2017 at 15:09.

  22. #22
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Interesting approach. Not quite what I was asking for, but it certainly looks useful. The DRelayTrap is still on/off focused, which limits its relay to only two sets of response targets. There is no way to send relay three different messages each to a distinct target. But hey, it does allow multiple on/off messages, which is cool.

  23. #23
    Member
    Registered: Jan 2012
    Location: Gèrmany
    Quote Originally Posted by LarryG View Post
    Interesting approach. Not quite what I was asking for, but it certainly looks useful. The DRelayTrap is still on/off focused, which limits its relay to only two sets of response targets. There is no way to send relay three different messages each to a distinct target. But hey, it does allow multiple on/off messages, which is cool.
    I know it's not exactly what you asked for that's why I said close
    I'm building up the framework and DRelayTrap is an intermediate result.

    Theoretically the hub script is already in the .nut file but beside parameter grabbing it does nothing.

    How it will look like:
    For each command you want you write DHubCommand="Parameter1=Value1;Parameter2=Value2;P3=V4..."
    Like:
    DHubTurnOn="Relay=+TurnOn+FireStim;Target=Player;Count=4";
    DHubTurnOff="Relay=[5]WaterStim;Target=[me]";
    DHubWhateverCommand="" (do default)


    Just had an idea of a different approach, maybe it will be done much faster than I expected, also it should be possible to do something like DHubTurnOn;DHubTurnOn2;DHubTurnOn2321

  24. #24
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    I was thinking of something like:

    [Scriptname]In1=InputMessage1;
    [Scriptname]Out1=OutputMessage1;
    [Scriptname]Targ1=OutputTarget1;
    [Scriptname]In1Cap=CapacitorValue;
    [Scriptname]Count1=Count;
    [Scriptname]FailChance1=FailureChance;
    [Scriptname]Delay1=Milliseconds;
    [Scriptname]DelayMax1=MaximumMilliseconds;
    [Scriptname]ExclusiveDelay1=ON/OFF or 1/0 or TRUE/FALSE;
    [Scriptname]Repeat=CountValue (-1 = repeat forever once triggered);
    [Scriptname]RepeatOff=RepeatOffMessage;
    ...
    [Scriptname]InN=InputMessageN;
    [Scriptname]OutN=OutputMessageN;
    [Scriptname]TargN=OutputTargetN;
    [Scriptname]InNCap=CapacitorValueN;
    [Scriptname]CountN=CountN;
    ...

  25. #25
    Member
    Registered: Jan 2012
    Location: Gèrmany

    v0.22

    Here it comes as you wished Larry and how I answered



    Download
    ------------v0.22--------------

    Parameter addition/fix
    •[ScriptName]Repeat, Delay, Count, CountOnly are now valid parameters. -> See DBaseTrap
    •When responsing to a FrobWorldBegin/End message. [source] will now point to the frobber. Before the script failed.

    Script Changes
    •FIXED: Count and Capacitor was not Savegame compatible, my bad...... now it is.
    ---NOTE: if you change a value there you need to execute a script_reload before saving the .mis.
    •DDrunkPlayer is Save Game compatible now as well.
    •DEditorTrap can now be used with DEditorTrapUseIngame=1 to count for example reloads.

    ScriptAdditions
    •DCompileTrap
    •DHub

    Squirrel changes
    •DBaseFunction is now the heart of everything. Takes a table and script name to perform stuff. Needed to cut it out of DBaseTrap to made it compatible with DHub. Might get reversed later when I revise the code and see it's not necessary.
    •Reloads won't reset counter and capacitor.



    -----
    Now to the main part of this new version, as Larry said a powerhouse.

    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 for now only be stop via a StopInfRepeats message to the Hub, for example via another action with Relay=StopInfRepeats;Target=[me]
    Count			The maximum number of times a action will be executed. Default =0 infinitely. All counts can for now be reset via a ResetCount message.
    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 example



    DCompileTrap
    On 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 moment a newline(made by enter) in the comments is used will be translated to \n and to not destroy your code you need to comment that \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 additions
    DArrayToString(ar,o="+")
    converts an array to a string with the character defined by o between them.

    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). For example if you know the first data is always the source the second the repeats left. Returned Array [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.
    Last edited by Daraan; 11th Apr 2017 at 14:50.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •