Create a free account to remove all ad content.

Author Topic: [Scripts] Script Tips  (Read 5184 times)

0 Members and 1 Guest are viewing this topic.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Script Tips
« on: August 15, 2016, 12:32:20 AM »
Script tips: Post yours below and I'll consider adding them to this OP.

I'll start it off with the first few. I'll also be tweeting the ones that will fit in a tweet.


Script tip #1:
You can use a variable anywhere you can use a number.

Script tip #2:
Substitute a variable for it's value in any [text] message by surrounding it in square brackets, eg. notify [Count=[count]]

Script tip #3:
Format a variable text value to x decimal places in [text[var:x]] by specifying # of decimal places after a colon after the var name.
e.g. notify [Radiation=[rad:2]] means the text will show the rad value truncated to 2 decimal places.

Script tip #4:
A simple coordinate based hash:
var [hash] = [31] + [rel:x] * [rel:z]
var [hash] = [31] * [hash] + [rel:y]
var [hash] = [31] * [hash] + [rel:z]
and to limit the hash to x number of digits use modulus [%] with a value of 10^x (like for a pin etc).
var [hash] = [hash] % [10000] // e.g. will limit it to 4 digits 10^4

Script tip #5:
Use a history value anywhere you can use a number by first loading it into a var.
e.g: var [bla] = [history:bla], now use bla in another command.

Script tip #6: (2.5 only)
A simple gamertag based hash:
var hash = [hash:[gamertag]]

Script tip #7:
Many parameters can be omitted, and where appropriate will use a default value. (See help/docs).

Script tip #8:
All variables (vars) are 64-bit floating-point values.

Script tip #9:
History values are 64-bit integer values. To store a fractional value from a variable to history, first multiply the variable by 10^x where x is the number of decimal places to store. Then when you want to use the fractional value again, divide by 10^x when assigning to a variable.

Script tip #10:
Notify and HudText are very useful debug tools. If you're not sure why something isn't working correctly then placing notify or HudText commands in the right places to display the relevant data on screen (history, variables etc) is a great help to find out where the script is going wrong.

Script tip #11:
Wait [100]
Loop                // delay omitted = default [16] i.e. same as Loop [16]
is the same as
Loop [116]

Script tip #12:
var assignments are processed strictly left to right, there is no operator preference.

Script tip #13:
Press the Back button to instantly exit the script editor window (no need to go through the B menu). If you've made changes to the script, you'll be prompted.

Script tip #14:
Press the Start button on any command that specifies another script to open that script in another editor window. It will automatically create a new script if it doesn't yet exist.

Script tip #15:
Whenever you use Loop, consider the highest delay possible for 'good enough' function. The higher the delay, the less potential for script lag.
« Last Edit: August 21, 2016, 03:36:57 AM by Craig »

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: Script Tips
« Reply #1 on: August 15, 2016, 12:32:30 AM »
.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: Script Tips
« Reply #2 on: August 15, 2016, 12:32:38 AM »
.

FatbFFA

  • Supreme Member
  • *
  • Posts: 2103
    • View Profile
    • ::)
  • Xbox: ETTP & Mr Zincy
Re: Script Tips
« Reply #3 on: August 15, 2016, 12:51:11 AM »
Script tip #7?:
It doesn't matter what order the parameters of a script function are filled in.

Script tip #8?:
Not all functions require all the parameters to be filled in.



Ill think of more as time goes on and just add them here.



crazytater94

  • Supreme Member
  • *
  • Posts: 2649
  • Mastering TM since 2011
    • View Profile
  • Xbox: crazytater94
  • PSN: crazytater94 (Inactive)
  • Steam: crazytater94
Re: Script Tips
« Reply #4 on: August 15, 2016, 02:55:12 AM »
Think of Var as the letters (X, Y, etc) in a math problem (X + 2 = Y).

There should be a clear marking about FOV where it says what number (1 or 100) that zooms in/out, for the frustum

A frustum is a trapezoid like prism and a ray is a line from 2 points

Adding a simple "Wait [50]" between script lines can drasticly improve the way it functions correctly

Looping scripts aren't really recommended for games with 4+ players due to lag


Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: Script Tips
« Reply #5 on: August 15, 2016, 04:07:52 AM »
It doesn't matter what order the parameters are in.
Actually it does matter. The only time it doesn't matter is when the parameters are named, like in the zone or item commands,

Not all commands require all the parameters to be filled in.
That's a good one. I'll post it as this: Many parameters can be omitted, and where appropriate will use a default value.

TheDestinedCrab

  • Legendary Member
  • *
  • Posts: 1401
  • Did you see that? Me neither.
    • View Profile
Re: Script Tips
« Reply #6 on: August 15, 2016, 04:10:06 AM »
9 times out of 10, your script wont work first time.  Keep trying.
Thanks Gold Knight for the amazing sig!

FatbFFA

  • Supreme Member
  • *
  • Posts: 2103
    • View Profile
    • ::)
  • Xbox: ETTP & Mr Zincy
Re: Script Tips
« Reply #7 on: August 15, 2016, 04:12:39 AM »
It doesn't matter what order the parameters are in.
Actually it does matter. The only time it doesn't matter is when the parameters are named, like in the zone or item commands,

It think i got it messed up with a shoutbox chat we had on how you were thinking of making it like this
SetBlock <x,y,z> <block> and you said it wouldn't matter which order you put them in.



Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: Script Tips
« Reply #8 on: August 15, 2016, 04:21:21 AM »
It doesn't matter what order the parameters are in.
Actually it does matter. The only time it doesn't matter is when the parameters are named, like in the zone or item commands,

It think i got it messed up with a shoutbox chat we had on how you were thinking of making it like this
SetBlock <x,y,z> <block> and you said it wouldn't matter which order you put them in.
Yes, part of the appeal of that syntax is that parameters can be in any order and easily omitted/defaulted.

Dryym

  • Supreme Member
  • *
  • Posts: 4336
  • What's yours is mine. ~TM's Resident Master Thief~
    • View Profile
  • Xbox: dryym
Re: Script Tips
« Reply #9 on: August 15, 2016, 07:51:06 AM »
View direction is a vector. Learn vector math.


Using the default [20] ms loop is not always the most efficient. Play around to find the highest loop interval you can have whilst still retaining script function.


When making gun or spell scripts, Put your particle effects after the intersect conditional block (Contrary to what Craig says.) If you want to make the particle only travel until it hits the target.


With the Explosion command, Radius controls the block damage radius. Strength controls the ~Craig, Insert function here.~


When using item swing events, Be sure to run the script that sets the event before testing. If using Item Commands, Be sure to run the script, And reequip the item before testing.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym