Author Topic:  [How to] Make Scripts  (Read 18198 times)

0 Members and 1 Guest are viewing this topic.

muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
[How to] Make Scripts
« on: April 08, 2014, 11:20:39 AM »


________________________________________

What are Scripts?

Scripts are commands which can be executed to perform multiple repetitive tasks at the click of a button.
They are used to automatically perform a task which would otherwise need to be done manually.

A Script is made by the player & saved to the world.
Admins of the world have access to the Script Menu, from which they can manually select to edit or run any script at any time.

Scripts can also be triggered by using a Script Block, which when powered On or powered Off will execute any script which has been assigned to it.



Where can they be used?
 
Scripts can be used in all world types.
Creative mode has access to all the command lines which can be used in scripts.
Dig Deep & Survival modes have limited command lines available. -No commands which can fabricate objects into the world are available in these modes, for obvious reasons.



How are they used?

Below are some tutorials to show how to use the Change Log, how to create scripts, how to set up Script blocks, examples of some of the commands, and a list of all the Command Lines & their functions.


________________________________________


Change Log

Spoiler for Hidden Content:
You can access your Change Log by pressing Start, going to Player, then selecting Change Log.

As the admin you can view the Change Logs of all the players currently in your world.

The Change Log is a record of every physical change you have made in the world, upto the last 1000 changes; be it clearing a block, flicking a switch, pasting a component, or anything else that changes the physical state of the world.


Clearing your Change Log:

You can Clear your Change Log at any time by going to: Player > Change Log > and Pressing A to Clear.


When creating a new script you have the option to make a 'New Script From Change Log'
This will import all the data from your Change Log.



________________________________________


Tutorials

Spoiler for Hidden Content:
Tutorial 1

How to:
  • Use the Change Log
  • Make a script
  • Execute a script manually
  • Setup a Script Block
  • Execute a script automatically, using a switch


Spoiler for Tutorial 1:
This is a nice easy first script to make; to help get used to how it all works.

Follow these steps to go through the above list while making a Hidden Doorway..




This is where the hidden doorway will be.
We'll want a switch that will open the doorway when it is powered On, & to close again when it is powered Off.

_____________________

Start with the doorway open, as shown above.
The first thing to do now is access & clear your Change Log by pressing Start > going to 'Player' > 'Change Log' > Select your name > Then Press A to clear your Change log.



_____________________


Now place the 2 blocks which will block the doorway



_____________________


Go to the Creative menu (down on D-pad) > go to 'Scripts' > Select 'New Script from Change Log'



You should have just 2 lines of script;
1: AddBlock [coordinates] [Woodplank] [O ]
2: AddBlock [coordinates] [Woodplank] [O ]

if you have any more lines, press Y on them to delete them. Only the 2 AddBlock lines are needed.

Rename your script as you wish & select 'Save and Exit'

-You have made the script which will 'add' the blocks.

_____________________


Now we need to make the script to 'remove the blocks, to reveal your hidden doorway

Time to clear your Change Log again  -Go to 'Player > Change Log > Select your name > Clear Change Log.

_____________________


Break the 2 blocks which you placed in the previous step



Go to; Creative menu > Scripts > New Script from Change Log > Save and Exit

-You have made the script to ClearBlocks

_____________________


Lets test them to make sure they work before proceeding..

Go to: Creative Menu > Scripts > Run Script > Select your first script
-You should see the blocks added back into your wall.

And again go to; Creative Menu > Scripts > Run Script > Select your second script
-You should see the blocks removed from your wall.


Time to place a Script block & switch. Place these wherever you want them, anywhere in your world.
I will just place them here;



Press Y then A on the Script block to enter the Setup for it.

When the Script block is powered On i want the doorway to open, so i will select my second script for this - The one which is set to ClearBlocks



When powered Off i want it to add the blocks, covering the passageway - so i will select my first script for this;



Done.
The hidden doorway will now open when the switch is On & close when it is Off.


________________________________________



Tutorial 2

How to:
  • Locate the coordinates of a block
  • Manually insert & edit a command line
  • Make a script without using the Change Log

Spoiler for Tutorial 2:
Follow these steps to go through the above list while making a AddInventory script.

This time we won't use the Change Log. Commands will be inserted & edited manually.

In this tutorial we will set this chest to have a stick added to it every time a player walks over a pressure plate.


To do this we will need the coordinates of the inventory we want to add to
-The chest in this example here is at [555,201,614]


Coordinates are displayed at the top right of the information window of all blocks. Press Y on any block to see its coordinates.
_______________

Go to Creative Menu > Scripts > New Script

Go down to the command lines & press Right on the D-pad to 'Insert Command'

Select 'AddInventory' then delete the line with 'nop' in it - this is not needed.



Edit the AddInventory command line by pressing A on it

You will now be able to edit the details of the script

Add the coordinates of the chest, the item you want added & quantity;





Save & Exit.
Your AddInventory script is done.
Now time to make the switch which activates it.

I want a pressure plate to activate my script so i will place a script block with a pressure plate on top here;



I will now go into the Script block setup & select my AddInventory script when it is powered On;




That is all that is needed to make an AddInventory script.
You got the coordinates, made a new script, added & edited a command line to make an AddInventory script
..Now a stick will now be added to that chest whenever someone walks on that pressure plate.


________________________________________



Tutorial 3

How to:
  • Notify players
  • Use delays
  • Setup a Script Block to act as a pressure plate


Spoiler for Tutorial 3:
Here we will make a script to display a message to new players arriving in the world.
-Delays will also be used to give players time to read each message.

For this we will need just a new script & script blocks to act as pressure plate.

_______________________

First thing to do is make the script;
Creative Menu > Scripts > New Script

Go down to line '1: nop' & press Right to Insert Command

Select Notify then press A to edit the command line
-i will edit my first notification to be globally displayed and say 'Welcome to the world'

like so;

(change local to global)
_______________________

Now i want a delay before the next message is displayed
-To do this, move to line 2 and Insert a Wait command

I want the delay to be about 2 seconds so i will edit the Wait command to Wait [2000]



-Here I have inserted a total of 3 Wait commands & 4 Notify commands into one script.

_______________________

I want this notification to trigger after players have loaded into the world & have moved out the spawn
-I will use the script blocks option to act as a pressure plate for this.

First I will place a script block and set it to run the Welcome script when powered On - & Act as pressure plate, like so;


I'll then copy and paste that script block around the spawn block, like so;



Note, the textures can be changed on script blocks.

That is all for this. It is done.
Now whenever someone walks over those script blocks, they will receive the Welcome messages

*Note* Everyone in the world will receive the notification. there is currently no way to limit the messages to zones or admins.


_________________

Other useful Global messages include;
Notifying players before shutting the server down.
Notifying players of events about to start or open.
Notifying players of new rules, admins, winners ect
Other information regarding your world



________________________________________



Tutorial 4

How to:
  • Paste a component by script
  • Reset the area (ClearRegion)


Spoiler for Hidden Content:
The easiest way is to first Clear your Changelog > Load the component you wish to paste > Paste it using the copytype you wish > Create new script from Change Log

I'll go through those steps in more detail below:
_________________

I'll have a bridge pasted across here when this button is pressed



_________________

Clear your Changelog  (Start > Player > Options > Change Log > Clear Change Log)

Load the component you wish to paste & paste it how & where you wish



_________________

Create a new script from ChangLog, rename it as you wish.



*Note* Make sure your command line is pasting a component from a component pack & not from your clipboard.
If you copy an area then paste it, your command line will say [clipboard] & it will paste whatever is currently saved in your clipboard -which is no good for this purpose.
Make sure to Save or Load the Component before pasting & creating your script.

_________________

So i've pasted the component & created the new script.. now i want the bridge to be removed when i power another button the other side of the bridge.

In this scenario it's easiest for me to just use a ClearRegion script to remove the bridge.

I'll place my Markers > clear my Change Log > Creative clear the area > (make any other edits you require to reset the area) > Create new script from Change Log.






________________________________________



Command Lines

See Script Command Documentation for a full, updated list of all the commands & their functions in 2.1

The list below is valid until that release as the format has changed and everything you need to know regarding Command Lines for your scripts can be found in the link above. goc


Spoiler for Hidden Content:
AddBlock [x,y,z] [block] [aux] 
-[x,y,z] specifies the location the block will be added
-[block] defines which block-type will be placed
-[aux] is used to determine which direction the block will be facing (This does not need to be included or used)
See AUX section below for more info on placing blocks in a particular direction.


AddInventory  [x,y,z] [item] [qty] 
-[x,y,z] specifies which storage unit to act upon.
-[item] defines which item or block to add.
-[qty] determines how many items will be added. The quantity.
*Note* Non-stackable items require a separate command line for each item.


ClearBlock [x,y,z]
Will clear the block at the [x,y,z] position


ClearInventory [x,y,z]
Will clear the entire inventory of any specified Crate, Chest, Locked Chest, Safe, Turret, Book Case or Economised Shop at the [x,y,z] location


ClearRegion [x,y,z] [x,y,z] [percent]
-[x,y,z] defines one corner of the region to be cleared.
-[x,y,z] defines the opposite corner of the region to be cleared.
The region can contain upto 500,000 blocks.
-[percent] determines how much percentage of the area to clear.  (This does not need to be included or used. The default value is 100%)


Comment
Is used by scriptmakers to make notes in the script itself.
They have no effect on the script or world.


Commit
Is used to force a graphics refresh. Normally the game will refresh the graphics after a script has run through its commands and completed.


CopyBlock [x,y,z] [x,y,z]
-[x,y,z] specifies the block to be copied.
-[x,y,z] determines the position the block will be copied to.


CopyRegion [x,y,z] [x,y,z] [x,y,z]
-[x,y,z] defines one corner of the region to copy.
-[x,y,z] defines the opposite corner of the region to copy.
-[x,y,z] determines the position the region will be copied to. The lowest coordinate of the copied region will be placed at this position.
The copied region will be facing the same direction as the area it was copied.
Regions can contain upto 500,000 blocks.



FillRegion [x,y,z] [x,y,z] [block]
-[x,y,z] defines one corner of the region to be filled
-[x,y,z] defines the opposite corner of the region to be filled
-[block] determines which blocktype will be used to fill the region


Fog [x,y,z] [radius] [duration] [intensity] [r,g,b] [visibility]
-[x,y,z] defines the central coordinate of the area to be affected by fog.
-[radius] determines how many blocks in each direction the fog will spread from [x,y,z].
-[duration] defines how many seconds the fog will be visible.
-[intensity] determines the Intensity of the fog. (1=lowest value/thinnest fog)(10=highest value/thickest fog)
-[r,g,b] defines the Red, Green and Blue color values of the fog.
-[visibility] defines the distance (in blocks) that the fog effect extends for, from the players viewpoint.

Spoiler for more info:
[x,z] - the y parameter can also be included for convenience, but is ignored. e.g. [100,200,25] and [100,25] are equivalent.
[intensity] is now a %, so valid values are 1 - 100.
The [visibility] parameter defines the distance (in blocks) that the fog effect extends for, from the players viewpoint (eyes). Valid values are 2 - 100. For Fog that has an intensity of 100%, this defines the distance the player can see before the Fog becomes an impenetrable wall. If the intensity is < 100%, the player will be able to see the fog effect start to drop off again after the distance defined by [visibility]. The formula used to calculate the distance is FarClip - ((FarClip - FogVisibility) * FogIntensity), where FarClip is the players view distance in blocks, FogVisibility is the total visibility of all the stacked fog effects the player is currently positioned inside, and FogIntensity is the total intensity of all the stacked fog effects the player is currently positioned inside.
Both color [r,g,b] and [visibility] are optional parameters (they can be omitted). If these parameters are omitted, the values used are [115+/-r,115+/-r,115+/-r] for color (where r is a random number between 0 - 25, and [50] for visibility.

-Craig

-Use an RGB color picker to get values.
*NOTE*  Multiple Fog scripts can be stacked upto a total intensity value of 10.
Command is not available until v2.04

info Video here


Marker [name] [delete|x,z] [admin]
-[name] defines the existing map marker to act upon, or names a new map marker.
-[delete|x,z] is used to delete an existing marker, or define the position of a new map marker.
-[admin] determines whether the map marker is visible only to admins.
*NOTE* Command is not available until v2.04


MoveBlock [x,y,z] [x,y,z]
-[x,y,z] defines the block to be moved
-[x,y,z] determines the position the block will be moved to
*Note* Moved storage units retain their inventory 


MoveRegion [x,y,z] [x,y,z] [x,y,z]
-[x,y,z] defines one corner of the region to be moved.
-[x,y,z] defines the opposite corner of the region to be moved.
-[x,y,z] determines the position the region will be moved to. The lowest coordinate of the copied region will be placed at this position.
Regions can contain upto 500,000 blocks.


Notify [message] [local|global]
This command will display custom notifications on the screen.
-[message] enter the text you want to display.
-[local] will display the notification only on the host machine.
-[global] will display the notification to all players in the world.


Paste [pack:component] [x,y,z] [facing] [copytype]
-[pack:component] enter the name of the component pack & the component you wish to paste.
-[x,y,z] defines the position the lowest coordinate of the component will be pasted.
-[facing] determines the direction it will be pasted. (see AUX for more info)
-[copytype] determines the paste method used, use either; [Overwrite] [NoOverwrite] or [Merge]


Rain [x,y,z] [radius] [duration] [intensity] [0,0,0]
-[x,y,z] defines the central coordinate of the area to be affected by rain.
-[radius] determines how many blocks in each direction the rain will spread from [x,y,z].
-[duration] defines how many seconds the rain will fall.
-[intensity] determines the intensity of the rain. (1=lowest value/lightest rain)(10=highest value/heaviest rain)
-[0,0,0] defines the RGB color value of the rain.

-Use an RGB color picker to get values.
*NOTE*  Multiple Rain scripts can be stacked upto a total intensity value of 10.
Command is not available until v2.04

info Video here


ReplaceRegion [x,y,z] [x,y,z] [block1] [block2]
This is used to replace the blocks in an area; like the 'Replace' creative tool.
-[x,y,z] defines one corner of the region
-[x,y,z] defines the opposite corner of the region
-[block1] defines which blocktype will be replaced
-[block2] determines which blocktype will be used to replace


Script [name]
This is used to run another script.
-[name] defines which script to run


SetPower [x,y,z] [on|off]
-[x,y,z] defines which block will be acted upon
-[on] sets power On
-[off] sets power Off


SetSwitch [x,y,z] [on|off|toggle]
-[x,y,z] defines which switch to act upon
-[on] sets switch On
-[off] sets switch Off
-[toggle] sets switch to its opposite state.


SpawnMob [x,y,z] [mobtype]
-[x,y,z] determines the location the mob will be spawned
-[mobtype] defines which mob will spawn


Spawnable mobs:
Spoiler for Hidden Content:
-Goblin
-Spider
-Zombie
-Dryad
-Djinn
-Orc
-Diablo
-Warewolf
-TrollChief
-Duck
-Sheep
-Alpaca
-AyrshireCow
-HighlandCow


Teleport [x,y,z] [x,y,z] [x,y,z] [absolute|relative]
-[x,y,z] defines one corner of the region to be teleported From
-[x,y,z] defines the opposite corner of the region to be teleported From
-[x,y,z] determines the location to be teleported To
-[absolute] players will be teleported to [x,y,z]
-[relative] players will be teleported to [x,y,z] + their position relative to the lowest coordinate of [x,y,z] [x,y,z]
(e.g. if player was 2 blocks South-East from the lowest coordinate in the 'teleport-From' region; they will be teleported 2 blocks South-East of [x,y,z])


Texture [x,y,z] [id]
-[x,y,z] defines the block to act upon
-[id] selects which texture to use
(Insert a number into the [id] parameter. The number used will correspond to the list of textures you have already chosen for that block type to use.
[1] will be the first texture selected After the default texture in the list
[15] will be the last texture in the list of possible textures for that block-type
[ 0] will be the default texture for the block type)

-consider using a 'Commit' command after changing textures to ensure the graphics refresh



Wait [milliseconds]
This command is used to make a script wait, or halt, for a specified amount of time before continuing on to its following command lines.
-[milliseconds] determines how long the script will wait before proceeding.
1000 milliseconds = 1 second


Waypoint [delete|x,y]
-[delete|x,y] determines whether the existing waypoint is deleted, or the location the new waypoint is placed on the map.
*NOTE* Command is not available until v2.04


Zone [name] [delete] [x,y,z] [x,y,z] [edit=on|off] [pvp=on|off] [fly=on|off] [mobs=on|off] [script=name]
-[name] defines the Zone to act upon, or names a new Zone.
-[delete] is used to delete the zone -(Remove this parameter if you do not wish to delete the zone)
-[x,y,z] defines one corner of the region to make a new zone.
-[x,y,z] defines the opposite corner of the region to make a new zone. -(Remove or ignore these parameters if you do not wish to make a new zone)
-[edit=on|off]
-[pvp=on|off]
-[fly=on|off]
-[mobs=on|off] these are used to toggle the zones settings
-[script=name] sets a script to be triggered when players enter the zone.



Optional Parameters

Spoiler for Hidden Content:
[qty], [percent], [aux], [facing], [copytype], [on.off.toggle]

All these parameters should be optional on the command line. If omitted (not used), the game uses a default value.

defaults:
[qty] = 1
[percent] = 100
[aux] = 0
[facing] = left
[copytype] = overwrite
[on.off.toggle] = toggle
[local.global] = local



________________________________________



Aux

Spoiler for Hidden Content:
This parameter is used to determine the direction, or position a block is placed

0 = Facing East, 1 = Facing South, 2 = Facing West, 3 = Facing North.

If the parameter is omitted it will use the default value: 0
   
_______________________

Aux Data - Auxiliary data

Every block in the map has 8 bits of data available to it called auxiliary data.

Bits 1 - 3 are used for orientation and state.

Bit 4 is used to store whether or not the block is the originally generated block or whether it has been changed since generation (by a player or something else). This bit cannot be manipulated by script commands.

Bits 5 - 8 are used to store the selected texture id's (value range = 0-15 = 16 possible textures).

In order to calculate the Aux values by hand, you must understand the binary number system and how to form separate values in different groups of bits and combine them to calculate the final number.

http://en.wikipedia.org/wiki/Binary_number
http://en.wikipedia.org/wiki/Bitwise_operation
http://en.wikipedia.org/wiki/Bit_manipulation
http://en.wikipedia.org/wiki/Bit_field
http://en.wikipedia.org/wiki/Mask_%28computing%29

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

Any block that has orientation: doors, trapdoors, stairs, ramps, one way glass, paintings, climbing ivy, torches, ladders, switches, buttons, beds, cylinders, use Bits 1 - 3 to define their orientation.


The following blocks can only face NSEW. They use Bits 1 and 2 to define the direction they face. A value from 0 to 3 inclusive. 0 = Facing East, 1 = Facing South, 2 = Facing West, 3 = Facing North.

Doors
Trapdoors
Stairs
Ramps
OneWayGlass
Beds
Cylinders

Cylinders are slightly different in that if Bit 3 = 0, then they are upright and Bits 1 - 2 are ignored. If Bit 3 = 1, then they are horizontal and Bits 1 - 2 are used to define their orientation.

Doors and Trapdoors use Bit 3 to define their state. 0 = Closed, 1 = Open.


The following blocks can be attached to the face of another block. They use Bits 1 - 3 to define the face they are attached to. A value from 0 to 5 inclusive. 0 = East face, 1 = South face, 2 = West face, 3 = North face, 4 = Top face, 5 = Bottom face.

ClimbingIvy
Switches
Buttons
Ladders
Torches
Paintings

Ladders and ClimbingIvy cannot be attached to the top or bottom face, so they cannot have a value higher than 3.

Torches cannot be attached to the bottom face, so they cannot have a value higher than 4.

Paintings are slightly different. They use Bits 1 - 2 to define the NSEW face they are attached to, but if Bit 3 = 1, then they are attached to the top face of the other block, facing up, and Bits 1 - 2 are now used to define their orientation.

Half Block:
Only uses Bit 1. If Bit 1 = 0, they are grounded, if Bit 1 = 1, they are raised.

Shops.
If Bit 1 = 1 they are economized.

Crops:
Bits 1 - 3 are used to define their current growth stage. Values 0 - 5 (6 stages).
Bits 5 - 8 are used to define the crop. Current values 0 - 2 (Wheat, Sugar Cane, Tomato).

Keys:
Bits 1 - 3 and 5 - 8 are used to define the key id.
0 = Skeleton key, 1 = Skull key. It's tricky to work this out by hand because Bit 4 is not used.

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

Textures

All blocks that can have their textures changed, including Paintings, use bits 5 - 8 of their Aux data to define the slot id for their texture.

0 = Default
1 - 15 = The slot id. That is the slot on the texture selection screen, not the block id itself.

e.g. If for Stairs you had Default, ConcreteBrick, WoodPlank, LimeStone and Glass selected as your textures, then a value of 3 will cause the stairs to be drawn with the LimeStone texture.



________________________________________



Tips


Spoiler for Hidden Content:
You can change the texture of Script Blocks & Buttons

You can find the coordinates of any block by prospecting it (pressing Y on it) - The coordinates are displayed in the top right of the information window.

When you prospect a block, its coordinates are copied & you can paste them into your scripts command lines by pressing LT

Scripts can run other scripts


Add Inventory:
Spoiler for Hidden Content:
Adding multiple instances:
The [1] parameter at the end of the command line determines the amount of items added by the script.
To add more than 1 item or block, modify the [1] parameter found at the end of the command line.

________________

Non-Stackable Items:
Adding items to an inventory which do not stack; such as weapons, tools, armour, or anything that requires 1 inventory slot per item will require a separate command line to add each item.

Example:  To add 2 swords to a chest you will need 2 command lines, each one placing a sword.
Example: 
1: AddInventory [xyz] [woodensword] [1]
2: AddInventory [xyz] [woodensword] [1]
______________

Note:
You cannot add to the inventory of players.


Command line for adding Gold Coins

Spoiler for Hidden Content:
AddInventory [x,y,z] [goldpieces] [1]

[3200000] is the maximum gold pieces a chest can hold - that is 3 million, 2 hundred thousand.
If you use a number too high, such as 9999999999 it will revert to default, only adding 1.



________________________________________



Extra Info

Spoiler for Hidden Content:
You cannot execute the same script more than once at the same time.
e.g. if you have circuitry which causes a script to be executed while it is already executing (from some other input), the circuit will ignore the script and continue.
This limitation was put in place to stop unexpected results for both the player and the game.

-Craig




________________________________________


« Last Edit: August 09, 2014, 07:16:26 AM by muD »

.ok

  • Supreme Member
  • *****
  • Posts: 2191
  • Awards Members who have unlocked the robotic avatar Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #1 on: April 08, 2014, 12:02:45 PM »

if there was a way you could make a vids/s that would help alot of ppl more

i can learn alot better visually instead of reading..but thats just me :P
« Last Edit: April 08, 2014, 12:32:42 PM by Ugh ThatZ NaZty »




muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #2 on: April 08, 2014, 12:07:32 PM »
if there was a way you could make a vids/s that would help alot of ppl more

i can learn alot better visually instead of reading..but thats just me :P
yes it would be a lot easier for you & me both. I'll look into it.

please could you edit your post and remove the quote. it's really long


OP updated, AddInventory script added.

.ok

  • Supreme Member
  • *****
  • Posts: 2191
  • Awards Members who have unlocked the robotic avatar Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #3 on: April 08, 2014, 12:33:53 PM »
yes it would be a lot easier for you & me both. I'll look into it.

please could you edit your post and remove the quote. it's really long


OP updated, AddInventory script added.
sorry :p




Marianek9

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • Awards
  • Xbox: Marianek9
Re: Scripts -[How to]-
« Reply #4 on: April 08, 2014, 01:15:16 PM »
muD, very helpfull post, thanks! :)
« Last Edit: April 08, 2014, 01:20:02 PM by Marianek9 »
My City: http://totalminerforums.net/index.php?topic=5257.0

*I'm sorry for my spelling mistakes, but I'm from Poland, and I dont speak English wery well ;)

DHGStealPackage

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
    • Awards
  • Xbox: DHGStealPackage
  • PSN: WhereThatWallAt
Re: Scripts -[How to]-
« Reply #5 on: April 08, 2014, 01:23:06 PM »
All of this will be edited & updated while i build up this guide of how to make basic scripts.

Following these steps should give a good enough understanding of how the change log & script blocks work

If there is any thing in particular you want to know how to do regarding scripts, feel free to ask


_____________________

Add / Remove blocks

Spoiler for Hidden Content:
In this example i'll make a Hidden Doorway 



This is where i want the hidden doorway.
I want a switch that will open the doorway when it is Powered On.

_____________________

I have my wall with the doorway open, as shown above.
The first thing to do now is 'Press Start > go to 'Player' > 'Change Log' > Select your name > Then Press A to clear your Change log



_____________________


Now place the 2 blocks which will block the doorway



_____________________


Go to the Creative menu (down on D-pad) > go to 'Scripts' > Select 'New Script from Change Log'



You should have just 2 lines of script;
1: AddBlock [xxx,xxx,xxx] [Woodplank] [O ]
2: AddBlock [xxx,xxx,xxx] [Woodplank] [O ]

if you have any more lines, press Y on them to delete them. Only the 2 AddBlock lines are needed.

Now Select 'Save and Exit'  -(Rename the script as you wish)

You have just made the script which will 'add' the blocks to hide your hidden doorway

_____________________


Now we need to make the script to 'remove the blocks, to reveal your hidden doorway

Time to clear your Change Log again  -Go to 'Player > Change Log > Select your name > Clear Change Log

_____________________


Break the 2 blocks which you placed in the previous step



Go to; Creative menu > Scripts > New Script from Change Log > Save and Exit

you have just created the script to remove those blocks

_____________________


Lets test them to make sure before proceeding..

Go to: Creative Menu > Scripts > Run Script > Select your first script
You should see the blocks added back into your wall.

And again go to; Creative Menu > Scripts > Run Script > Select your second script
You should see the blocks removed from your wall.

Ok, all good so far..
Time to place the Script block & switch. Place these wherever you want them
I will just place them here;



Press Y then A on the Script block to enter the setup for it.

When the Script block is Powered On i want the doorway to open, so i will select my second script for this - The one which is set to Clear Blocks



When Powered Off i want it to add the blocks, covering the passageway - so i will select my first script for this;



That is all that is needed for a simple Add/Remove script, using the Change Log

________________________


Add Inventory

Spoiler for Hidden Content:
This time we won't use the Change Log.

I want this chest to have a stick added to it every time a player walks over a pressure plate - so i can know how many times my hidden passageway has been accessed.

First thing to do is note the coordinates of the inventory you want to add to - The chest in this example here is at [555,201,614]


_______________

Go to Creative Menu > Scripts > New Script

Go down to the command lines & press Right on the D-pad to 'Insert Command'

Select 'AddInventory' then delete the line with 'nop' in it - this is not needed.



Edit the AddInventory command by pressing A on it

You will now be able to edit the details of the script
I will add the coordinates of my chest, the item i want added & quantity;





Save & Exit.
Your AddInventory script is done. Now time to make the switch which activates it.

I want a pressure plate to activate my script so i will place a script block with a pressure plate on top here;



I will now go into the Script block setup & select my AddInventory script when it is Powered On;



That is all that is needed to make an AddInventory script.
A stick will now be added to that chest whenever someone walks on that pressure plate.

That should give a good enough understanding of the basics & necessary methods for later going on to produce complicated circuits.

______________________

To do;
Move Block
Copy / Move / Replace / Clear Region
Comment / Commit / Notify
Set Power / Set Switch / Spawn Mob
Paste / Texture
Wait / Script


I tend to use the place and remove region commands. It keeps the script shorter and easier to read.

muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #6 on: April 08, 2014, 01:40:37 PM »
I tend to use the place and remove region commands. It keeps the script shorter and easier to read.
I will add examples of all the commands
the 2 so far should be enough info on the most relevant functions for now; change log, script blocks, switches, editing command lines ect

really impressed with the way Craig has designed all the Ui & options for it.. the change log is so useful

Jaz

  • Supreme Member
  • *****
  • Posts: 2934
  • ヽ(`⌒)ノ
  • Awards Awarded to exemplary forum members 3 years on site+600 posts Was in the top 10 of the forum stats page as of 4/12/15 Former MotM winners 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
    • cluckinbellhappychicken
    • Awards
  • Xbox: Jaz the MAN 2
  • PSN: Jaz_the_MAN_2
  • Steam: Jaz the MAN 2
Re: Scripts -[How to]-
« Reply #7 on: April 08, 2014, 02:38:42 PM »
when you first start a command it says "nop" what does this mean?

"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones" ~ Albert Einstein

SwiftGeneration

  • Elite Member
  • *****
  • Posts: 639
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: SwiftGeneration
Re: Scripts -[How to]-
« Reply #8 on: April 08, 2014, 03:34:59 PM »
when you first start a command it says "nop" what does this mean?

Nigel's Overgrown Pram
;)
Old Member Of Team Craft
Old Member Of Builders Unit
~~~~~~~~~~~~
Twitter = SabreSwiftYT
Youtube =
Skype = Swift Generation

.ok

  • Supreme Member
  • *****
  • Posts: 2191
  • Awards Members who have unlocked the robotic avatar Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #9 on: April 08, 2014, 06:32:50 PM »
i was messing around w the inventory part and i gugured a way to fill all of the what was crates now chests with max gold
because previouslu when i build that arcade i had crates and what i ended up was filling all 100-200 crates that were under the arcade blocks with gold to the max amount you could add or 65K x 20
and that took 6 hrs to do

now i have or will have it to where when smne walks in or out of the arcade they step on 1 of 2 pressure plates that fills the current 2 chests i have in fromt until i open the map later where i can punch in each of the chests xyz

but now ill never have to worry about ppl taking more gold than they need or worry about finding each chest that has gold missing & filling those spots up




.ok

  • Supreme Member
  • *****
  • Posts: 2191
  • Awards Members who have unlocked the robotic avatar Donated a giveaway prize. (Must be a prize of cash value.) 3 years on site+600 posts 2 years on site+300 posts Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #10 on: April 08, 2014, 06:44:12 PM »
i also came up with a really awesome and complicated idea
but if i wanna even attempt it i need to know

is there a way to run multiple scripts at once
is there a way to time the commands
can you delay say script a for like 5 seconds....then the moment a gets delayed to have a timer on b or c where they perform a command after....like how a redstone repeater has 3 delays...would it be possible for if u flick a swich script a would be on tick 4,script b ould be on tick 3 and script c would be on tick 2 or 1 and have them perform their task bfr either meeting back together or waiting to perform on another comand

if ur able to understand my idea and its possible
then h4dhhg33696giugw356ttyyyyutxst




muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #11 on: April 08, 2014, 07:35:37 PM »
i also came up with a really awesome and complicated idea
but if i wanna even attempt it i need to know

is there a way to run multiple scripts at once
is there a way to time the commands
can you delay say script a for like 5 seconds....then the moment a gets delayed to have a timer on b or c where they perform a command after....like how a redstone repeater has 3 delays...would it be possible for if u flick a swich script a would be on tick 4,script b ould be on tick 3 and script c would be on tick 2 or 1 and have them perform their task bfr either meeting back together or waiting to perform on another comand

if ur able to understand my idea and its possible
then h4dhhg33696giugw356ttyyyyutxst
all sounds do-able
sounds like you could use just one script block & put delays in it for that. may be easier.
check out the Wait command - you will want to use Wait [5000] for a 5 second delay

For example;
1: Wait [5000]
2: SetPower [x,y,z] [on]
3: Wait [4000]
4: SetSwitch [x,y,z] [on]
5: Wait [3000]
6: SpawnMob [x,y,z] [sheep]

& yes you can also run scripts from scripts - or have simultaneous scripts to run
7: Script [name]

i'll make a thing for OP on delays & running scripts from scripts sometime. maybe tomoz

whatever you had in mind, it sounds possible
« Last Edit: April 08, 2014, 07:37:38 PM by muD »

bob

  • Administrator
  • Legendary Member
  • ******
  • Posts: 1342
  • Awards Award for outstanding excellence in the field of bob 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
    • Awards
Re: Scripts -[How to]-
« Reply #12 on: April 08, 2014, 07:43:57 PM »
Once again, great topic. Thanks for writing it up. Well deserving of a sticky

muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #13 on: April 08, 2014, 07:46:17 PM »
i was messing around w the inventory part and i gugured a way to fill all of the what was crates now chests with max gold
because previouslu when i build that arcade i had crates and what i ended up was filling all 100-200 crates that were under the arcade blocks with gold to the max amount you could add or 65K x 20
and that took 6 hrs to do

now i have or will have it to where when smne walks in or out of the arcade they step on 1 of 2 pressure plates that fills the current 2 chests i have in fromt until i open the map later where i can punch in each of the chests xyz

but now ill never have to worry about ppl taking more gold than they need or worry about finding each chest that has gold missing & filling those spots up

:) cool
have you used an 'add/remove block' script to make the arcade players safe from interference yet?
sure they'd all appreciate it

see some plans for that & other ideas here http://totalminerforums.net/index.php?topic=4807.msg58749#msg58749

muD

  • Legendary Member
  • *****
  • Posts: 1177
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members Day 1 w/25+ posts (4/12/13) 2 years on site+300 posts Former MotM winners 1 year on site+100 posts
    • View Profile
    • Awards
Re: Scripts -[How to]-
« Reply #14 on: April 08, 2014, 07:48:52 PM »
Once again, great topic. Thanks for writing it up. Well deserving of a sticky
no worries :) thanks bob