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

0 Members and 1 Guest are viewing this topic.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
[Scripts] 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: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Script Tips
« Reply #1 on: August 15, 2016, 12:32:30 AM »
.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Script Tips
« Reply #2 on: August 15, 2016, 12:32:38 AM »
.

TM Charles

  • Supreme Member
  • *****
  • Posts: 2089
  • Awards Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts 1 year on site+100 posts Was in the top 10 of the forum stats page as of 4/12/15
    • View Profile
    • ::)
    • Awards
  • 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: 2588
  • Mastering TM since 2011
  • Awards Awarded to exemplary forum members Members who have unlocked the robotic avatar 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Former MotM winners Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
  • 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: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • 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: 1310
  • Did you see that? Me neither.
  • Awards 3 years on site+600 posts Donated a giveaway prize. (Must be a prize of cash value.) 2 years on site+300 posts 1 year on site+100 posts
    • View Profile
    • Awards
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!

TM Charles

  • Supreme Member
  • *****
  • Posts: 2089
  • Awards Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts 1 year on site+100 posts Was in the top 10 of the forum stats page as of 4/12/15
    • View Profile
    • ::)
    • Awards
  • 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: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • 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.

Curmescius

  • Supreme Member
  • *****
  • Posts: 4265
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • 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

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Script Tips
« Reply #10 on: August 16, 2016, 06:48:01 PM »
bump

Lunar

  • Elite Member
  • *****
  • Posts: 938
  • The God of the Galaxy
  • Awards 2 years on site+300 posts 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Qvzw
  • PSN: Widumn_Boise
Re: Script Tips
« Reply #11 on: August 16, 2016, 09:52:26 PM »
You should just sticky this, it would be really useful for most people.

Curmescius

  • Supreme Member
  • *****
  • Posts: 4265
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: dryym
Re: Script Tips
« Reply #12 on: September 05, 2016, 06:44:42 PM »
Use [[coord]] in your history names to input the coordinates of the block the script was run from.

History checks with this name will check if the block's coordinates match any existing history.

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

Redsparx

  • Jr. Member
  • **
  • Posts: 47
  • If it doesnt drop anything, it not worth killing.
    • View Profile
    • Awards
  • Xbox: Redsparx
Re: Script Tips
« Reply #13 on: September 06, 2016, 03:05:35 PM »
If you want have a script's coordinates at your spot on the map, use: [letter]rel:[x offset],[y offset],[z offset]