Difference between revisions of "Scripting"

From 4Dimensions
Jump to: navigation, search
Line 8: Line 8:
  
 
Here ''nop'' is the '''command''', ''actor'' is the '''variable''', ''exp'' is the '''field''' and ''1000'' is the '''subfield'''.
 
Here ''nop'' is the '''command''', ''actor'' is the '''variable''', ''exp'' is the '''field''' and ''1000'' is the '''subfield'''.
 +
 +
In scripts, a uid is the character '}' followed by a number. The number is the id of a mob, player, object or room. A uid is used to manipulate what it points to, from any script.
 +
 +
To make it easier to debug scripts, a [[Scripting:Debugger|scripting debugger]] is available. It can set breakpoints, view or change variables, step through a trigger, and show the result of any scripting expression.
  
 
All commands, fields and variables are grouped alphabetically:
 
All commands, fields and variables are grouped alphabetically:
Line 15: Line 19:
  
 
==A==
 
==A==
 +
*[[#aff_ac|aff_ac]]
 +
*[[#aff_age|aff_age]]
 +
*[[#aff_breath_def|aff_breath_def]]
 +
*[[#aff_cha|aff_cha]]
 +
*[[#aff_con|aff_con]]
 +
*[[#aff_coolness|aff_coolness]]
 +
*[[#aff_damroll|aff_damroll]]
 +
*[[#aff_dex|aff_dex]]
 +
*[[#aff_hitroll|aff_hitroll]]
 +
*[[#aff_int|aff_int]]
 +
*[[#aff_maxhit|aff_maxhit]]
 +
*[[#aff_maxmana|aff_maxmana]]
 +
*[[#aff_maxmove|aff_maxmove]]
 +
*[[#aff_mine_bonus|aff_mine_bonus]]
 +
*[[#aff_mine_protection|aff_mine_protection]]
 +
*[[#aff_mine_speed|aff_mine_speed]]
 +
*[[#aff_mine_stealth|aff_mine_stealth]]
 +
*[[#aff_paralyze_def|aff_paralyze_def]]
 +
*[[#aff_petrify_def|aff_petrify_def]]
 +
*[[#aff_rod_def|aff_rod_def]]
 +
*[[#aff_regen_hit|aff_regen_hit]]
 +
*[[#aff_regen_mana|aff_regen_mana]]
 +
*[[#aff_regen_move|aff_regen_move]]
 +
*[[#aff_speed|aff_speed]]
 +
*[[#aff_spell_def|aff_spell_def]]
 +
*[[#aff_str|aff_str]]
 +
*[[#aff_wis|aff_wis]]
 
*[[#assemble|assemble]]
 
*[[#assemble|assemble]]
 
*[[#assemblycheck|assemblycheck]]
 
*[[#assemblycheck|assemblycheck]]
Line 27: Line 58:
 
*[[#clanrank|clanrank]]
 
*[[#clanrank|clanrank]]
 
*[[#class_tier|class_tier]]
 
*[[#class_tier|class_tier]]
 +
*[[#colour_value|colour_value]]
 +
*[[#contained_by|contained_by]]
 
*[[#cool|cool]]
 
*[[#cool|cool]]
 
==D==
 
==D==
 
*[[#damroll|damroll]]
 
*[[#damroll|damroll]]
 
*[[#dest|dest]]
 
*[[#dest|dest]]
 +
*[[#dg_affect|dg_affect]]
 +
*[[#dg_dest|dg_dest]]
 +
*[[#dg_letter|dg_letter]]
 +
*[[#dg_peek|dg_peek]]
 +
*[[#dimension|dimension]]
 +
*[[#dyecount|dyecount]]
 
==E==
 
==E==
 
*[[#exp_needed|exp_needed]]
 
*[[#exp_needed|exp_needed]]
 
==F==
 
==F==
 +
*[[#flag|flag]]
 
*[[#follower_in_room|follower_in_room]]
 
*[[#follower_in_room|follower_in_room]]
 
*[[#forget_subskills|forget_subskills]]
 
*[[#forget_subskills|forget_subskills]]
 +
*[[#function|function]]
 
==G==
 
==G==
 
==H==
 
==H==
 +
*[[#has_pos|has_pos]]
 +
*[[#has_script|has_script]]
 
*[[#hitroll|hitroll]]
 
*[[#hitroll|hitroll]]
 
*[[#hunger|hunger]]
 
*[[#hunger|hunger]]
Line 43: Line 86:
 
*[[#hunting|hunting]]
 
*[[#hunting|hunting]]
 
==I==
 
==I==
 +
*[[#in_material_group|in_material_group]]
 +
*[[#innate|innate]]
 +
*[[#insert_word|insert_word]]
 
*[[#is_cheater|is_cheater]]
 
*[[#is_cheater|is_cheater]]
 
*[[#is_flying|is_flying]]
 
*[[#is_flying|is_flying]]
Line 61: Line 107:
 
*[[#longdesc|longdesc]]
 
*[[#longdesc|longdesc]]
 
==M==
 
==M==
 +
*[[#material_name|material_name]]
 +
*[[#material_value|material_value]]
 
*[[#maxcarriedamount|maxcarriedamount]]
 
*[[#maxcarriedamount|maxcarriedamount]]
 
*[[#maxcarriedweight|maxcarriedweight]]
 
*[[#maxcarriedweight|maxcarriedweight]]
 +
*[[#max_quality_value|max_quality_value]]
 
*[[#maxstamina|maxstamina]]
 
*[[#maxstamina|maxstamina]]
 
*[[#mid|mid]]
 
*[[#mid|mid]]
 
==N==
 
==N==
 
*[[#next_follower|next_follower]]
 
*[[#next_follower|next_follower]]
 +
*[[#next_in_list|next_in_list]]
 
*[[#nographics|nographics]]
 
*[[#nographics|nographics]]
 +
*[[#num_of_repairs|num_of_repairs]]
 
==O==
 
==O==
 
*[[#omr|omr]]
 
*[[#omr|omr]]
 +
*[[#origin|origin]]
 +
*[[#owned_by|owned_by]]
 
==P==
 
==P==
 
*[[#people|people]]
 
*[[#people|people]]
Line 76: Line 129:
 
*[[#pkkills|pkkills]]
 
*[[#pkkills|pkkills]]
 
*[[#pkpoints|pkpoints]]
 
*[[#pkpoints|pkpoints]]
 +
*[[#playeruid|playeruid]]
 +
*[[#purgemob|purgemob]]
 
==Q==
 
==Q==
 +
*[[#quality_value|quality_value]]
 
==R==
 
==R==
 
*[[#remorts|remorts]]
 
*[[#remorts|remorts]]
 +
*[[#repair|repair]]
 +
*[[#replace_letter|replace_letter]]
 +
*[[#replace_word|replace_word]]
 +
*[[#restring|restring]]
 
*[[#ridden_by|ridden_by]]
 
*[[#ridden_by|ridden_by]]
 
*[[#riding|riding]]
 
*[[#riding|riding]]
 
*[[#rpgroup|rpgroup]]
 
*[[#rpgroup|rpgroup]]
 
==S==
 
==S==
 +
*[[#save_affects|save_affects]]
 +
*[[#sector|sector]]
 +
*[[#set_colour_name|set_colour_name]]
 +
*[[#set_material_name|set_material_name]]
 +
*[[#set_quality_name|set_quality_name]]
 
*[[#speed|speed]]
 
*[[#speed|speed]]
 +
*[[#stage_value|stage_value]]
 
*[[#stamina|stamina]]
 
*[[#stamina|stamina]]
 
*[[#subdecrease|subdecrease]]
 
*[[#subdecrease|subdecrease]]
Line 93: Line 159:
 
==U==
 
==U==
 
==V==
 
==V==
 +
*[[#val|val]]
 
==W==
 
==W==
 
==X==
 
==X==
 
==Y==
 
==Y==
 
==Z==
 
==Z==
 +
*[[#zonename|zonename]]
 +
 +
 +
 +
The ''aff_'' fields are used to get or change the stats of an object.
 +
 +
==aff_ac==
 +
 +
    %object.aff_ac%
 +
 +
Returns the AC an object gives.
 +
 +
    nop %object.aff_ac(-5)%
 +
 +
Sets the AC of an object to -5.
 +
 +
 +
==aff_age==
 +
 +
    %object.aff_age%
 +
 +
Returns the age an object gives.
 +
 +
    nop %object.aff_age(125)%
 +
 +
Sets the age of an object to 125.
 +
 +
 +
==aff_breath_def==
 +
 +
    %object.aff_breath_def%
 +
 +
Returns the breath defense an object gives.
 +
 +
    nop %object.aff_breath_def(50)%
 +
 +
Sets the breath defense of an object to 50.
 +
 +
 +
==aff_cha==
 +
 +
    %object.aff_cha%
 +
 +
Returns the charisma an object gives.
 +
 +
    nop %object.aff_cha(2)%
 +
 +
Sets the charisma of an object to 2.
 +
 +
 +
==aff_con==
 +
 +
    %object.aff_con%
 +
 +
Returns the constitution an object gives.
 +
 +
    nop %object.aff_con(-3)%
 +
 +
Sets the constitution of an object to -3.
 +
 +
 +
==aff_coolness==
 +
 +
    %object.aff_coolness%
 +
 +
Returns the coolness an object gives.
 +
 +
    nop %object.aff_coolness(5)%
 +
 +
Sets the coolness of an object to 5.
 +
 +
 +
==aff_damroll==
 +
 +
    %object.aff_damroll%
 +
 +
Returns the damroll an object gives.
 +
 +
    nop %object.aff_damroll(3)%
 +
 +
Sets the damroll of an object to 3.
 +
 +
 +
==aff_dex==
 +
 +
    %object.aff_dex%
 +
 +
Returns the dexterity an object gives.
 +
 +
    nop %object.aff_dex(1)%
 +
 +
Sets the dexterity of an object to 1.
 +
 +
 +
==aff_hitroll==
 +
 +
    %object.aff_hitroll%
 +
 +
Returns the hitroll an object gives.
 +
 +
    nop %object.aff_hitroll(2)%
 +
 +
Sets the hitroll of an object to 2.
 +
 +
 +
==aff_int==
 +
 +
    %object.aff_int%
 +
 +
Returns the intelligence an object gives.
 +
 +
    nop %object.aff_int(3)%
 +
 +
Sets the intelligence of an object to 3.
 +
 +
 +
==aff_maxhit==
 +
 +
    %object.aff_maxhit%
 +
 +
Returns the maximum hitpoints an object gives.
 +
 +
    nop %object.aff_maxhit(700)%
 +
 +
Sets the maximum hitpoints of an object to 700.
 +
 +
 +
==aff_maxmana==
 +
 +
    %object.aff_mana%
 +
 +
Returns the maximum mana an object gives.
 +
 +
    nop %object.aff_maxmana(2000)%
 +
 +
Sets the maximum mana of an object to 2000.
 +
 +
 +
==aff_maxmove==
 +
 +
    %object.aff_maxmove%
 +
 +
Returns the maximum moves an object gives.
 +
 +
    nop %object.aff_maxmove(500)%
 +
 +
Sets the maximum moves of an object to 500.
 +
 +
 +
==aff_mine_bonus==
 +
 +
    %object.aff_mine_bonus%
 +
 +
Returns the mine bonus an object gives.
 +
 +
    nop %object.aff_mine_bonus(10)%
 +
 +
Sets the mine bonus of an object to 10.
 +
 +
 +
==aff_mine_protection==
 +
 +
    %object.aff_mine_protection%
 +
 +
Returns the mine protection an object gives.
 +
 +
    nop %object.aff_mine_protection(25)%
 +
 +
Sets the mine protection of an object to 25.
 +
 +
 +
==aff_mine_speed==
 +
 +
    %object.aff_mine_speed%
 +
 +
Returns the mine speed an object gives.
 +
 +
    nop %object.aff_mine_speed(30)%
 +
 +
Sets the mine speed of an object to 30.
 +
 +
 +
==aff_mine_stealth==
 +
 +
    %object.aff_mine_stealth%
 +
 +
Returns the mine stealth an object gives.
 +
 +
    nop %object.aff_mine_stealth(10)%
 +
 +
Sets the mine stealth of an object to 10.
 +
 +
 +
==aff_paralyze_def==
 +
 +
    %object.aff_paralyze_def%
 +
 +
Returns the paralyze defense an object gives.
 +
 +
    nop %object.aff_paralyze_def(5)%
 +
 +
Sets the paralyze defense of an object to 5.
 +
 +
 +
==aff_petrify_def==
 +
 +
    %object.aff_petrify_def%
 +
 +
Returns the petrify defense an object gives.
 +
 +
    nop %object.aff_petrify_def(3)%
 +
 +
Sets the petrify defense of an object to 3.
 +
 +
 +
==aff_rod_def==
 +
 +
    %object.aff_rod_def%
 +
 +
Returns the rod defense an object gives.
 +
 +
    nop %object.aff_rod_def(-2)%
 +
 +
Sets the rod defense of an object to -2.
 +
 +
 +
==aff_regen_hit==
 +
 +
    %object.aff_regen_hit%
 +
 +
Returns the hitpoint regeneration an object gives.
 +
 +
    nop %object.aff_regen_hit(10)%
 +
 +
Sets the hitpoint regeneration of an object to 10.
 +
 +
 +
==aff_regen_mana==
 +
 +
    %object.aff_regen_mana%
 +
 +
Returns the mana regeneration an object gives.
 +
 +
    nop %object.aff_regen_mana(5)%
 +
 +
Sets the mana regeneration of an object to 5.
 +
 +
 +
==aff_regen_move==
 +
 +
    %object.aff_regen_move%
 +
 +
Returns the move regeneration an object gives.
 +
 +
    nop %object.aff_regen_move(10)%
 +
 +
Sets the move regeneration of an object to 10.
 +
 +
 +
==aff_speed==
 +
 +
    %object.aff_speed%
 +
 +
Returns the speed an object gives.
 +
 +
    nop %object.aff_speed(50)%
 +
 +
Sets the speed of an object to 50.
 +
 +
 +
==aff_spell_def==
 +
 +
    %object.aff_spell_def%
 +
 +
Returns the spell defense an object gives.
 +
 +
    nop %object.aff_spell_def(10)%
 +
 +
Sets the spell defense of an object to 10.
 +
 +
 +
==aff_str==
 +
 +
    %object.aff_str%
 +
 +
Returns the strength an object gives.
 +
 +
    nop %object.aff_str(2)%
 +
 +
Sets the strength of an object to 2.
 +
 +
 +
==aff_wis==
 +
 +
    %object.aff_wis%
 +
 +
Returns the wisdom an object gives.
 +
 +
    nop %object.aff_wis(-1)%
 +
 +
Sets the wisdom of an object to -1.
 +
 +
 +
==assemble==
 +
 +
    nop %actor.assemble(123)%
 +
 +
If the inventory of ''actor'' holds the ingredients of the assembly, then they are replaced by object 123.
 +
 +
 +
==assemblycheck==
 +
 +
    %actor.assemblycheck(123)%
 +
 +
Returns 1 if actor has the ingredients to assemble object 123.
 +
 +
 +
==body==
 +
 +
    %actor.body%
 +
 +
Returns all extra body positions.
 +
 +
    nop %player.body(crest)%
 +
 +
Toggles the extra body position ''crest''.
 +
 +
 +
==bodycheck==
 +
 +
    %player.bodycheck(wield)
 +
 +
Returns 1 if ''player'' has the body position ''wield''.
 +
 +
    %player.bodycheck(crest)
 +
 +
Returns 1 if ''player'' has the extra body position ''crest'' (mobs have all body positions).

Revision as of 15:45, 3 February 2017

There's a good scripting reference at TBA, but there are differences with 4D's scripting commands. These pages aim to give an overview of these commands. One notable difference is crafting, for which several new commands and fields have been added.

To give an example of the terms used in these pages, consider this line:

   nop %actor.exp(1000)%

Here nop is the command, actor is the variable, exp is the field and 1000 is the subfield.

In scripts, a uid is the character '}' followed by a number. The number is the id of a mob, player, object or room. A uid is used to manipulate what it points to, from any script.

To make it easier to debug scripts, a scripting debugger is available. It can set breakpoints, view or change variables, step through a trigger, and show the result of any scripting expression.

All commands, fields and variables are grouped alphabetically:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z


The aff_ fields are used to get or change the stats of an object.

aff_ac

   %object.aff_ac%

Returns the AC an object gives.

   nop %object.aff_ac(-5)%

Sets the AC of an object to -5.


aff_age

   %object.aff_age%

Returns the age an object gives.

   nop %object.aff_age(125)%

Sets the age of an object to 125.


aff_breath_def

   %object.aff_breath_def%

Returns the breath defense an object gives.

   nop %object.aff_breath_def(50)%

Sets the breath defense of an object to 50.


aff_cha

   %object.aff_cha%

Returns the charisma an object gives.

   nop %object.aff_cha(2)%

Sets the charisma of an object to 2.


aff_con

   %object.aff_con%

Returns the constitution an object gives.

   nop %object.aff_con(-3)%

Sets the constitution of an object to -3.


aff_coolness

   %object.aff_coolness%

Returns the coolness an object gives.

   nop %object.aff_coolness(5)%

Sets the coolness of an object to 5.


aff_damroll

   %object.aff_damroll%

Returns the damroll an object gives.

   nop %object.aff_damroll(3)%

Sets the damroll of an object to 3.


aff_dex

   %object.aff_dex%

Returns the dexterity an object gives.

   nop %object.aff_dex(1)%

Sets the dexterity of an object to 1.


aff_hitroll

   %object.aff_hitroll%

Returns the hitroll an object gives.

   nop %object.aff_hitroll(2)%

Sets the hitroll of an object to 2.


aff_int

   %object.aff_int%

Returns the intelligence an object gives.

   nop %object.aff_int(3)%

Sets the intelligence of an object to 3.


aff_maxhit

   %object.aff_maxhit%

Returns the maximum hitpoints an object gives.

   nop %object.aff_maxhit(700)%

Sets the maximum hitpoints of an object to 700.


aff_maxmana

   %object.aff_mana%

Returns the maximum mana an object gives.

   nop %object.aff_maxmana(2000)%

Sets the maximum mana of an object to 2000.


aff_maxmove

   %object.aff_maxmove%

Returns the maximum moves an object gives.

   nop %object.aff_maxmove(500)%

Sets the maximum moves of an object to 500.


aff_mine_bonus

   %object.aff_mine_bonus%

Returns the mine bonus an object gives.

   nop %object.aff_mine_bonus(10)%

Sets the mine bonus of an object to 10.


aff_mine_protection

   %object.aff_mine_protection%

Returns the mine protection an object gives.

   nop %object.aff_mine_protection(25)%

Sets the mine protection of an object to 25.


aff_mine_speed

   %object.aff_mine_speed%

Returns the mine speed an object gives.

   nop %object.aff_mine_speed(30)%

Sets the mine speed of an object to 30.


aff_mine_stealth

   %object.aff_mine_stealth%

Returns the mine stealth an object gives.

   nop %object.aff_mine_stealth(10)%

Sets the mine stealth of an object to 10.


aff_paralyze_def

   %object.aff_paralyze_def%

Returns the paralyze defense an object gives.

   nop %object.aff_paralyze_def(5)%

Sets the paralyze defense of an object to 5.


aff_petrify_def

   %object.aff_petrify_def%

Returns the petrify defense an object gives.

   nop %object.aff_petrify_def(3)%

Sets the petrify defense of an object to 3.


aff_rod_def

   %object.aff_rod_def%

Returns the rod defense an object gives.

   nop %object.aff_rod_def(-2)%

Sets the rod defense of an object to -2.


aff_regen_hit

   %object.aff_regen_hit%

Returns the hitpoint regeneration an object gives.

   nop %object.aff_regen_hit(10)%

Sets the hitpoint regeneration of an object to 10.


aff_regen_mana

   %object.aff_regen_mana%

Returns the mana regeneration an object gives.

   nop %object.aff_regen_mana(5)%

Sets the mana regeneration of an object to 5.


aff_regen_move

   %object.aff_regen_move%

Returns the move regeneration an object gives.

   nop %object.aff_regen_move(10)%

Sets the move regeneration of an object to 10.


aff_speed

   %object.aff_speed%

Returns the speed an object gives.

   nop %object.aff_speed(50)%

Sets the speed of an object to 50.


aff_spell_def

   %object.aff_spell_def%

Returns the spell defense an object gives.

   nop %object.aff_spell_def(10)%

Sets the spell defense of an object to 10.


aff_str

   %object.aff_str%

Returns the strength an object gives.

   nop %object.aff_str(2)%

Sets the strength of an object to 2.


aff_wis

   %object.aff_wis%

Returns the wisdom an object gives.

   nop %object.aff_wis(-1)%

Sets the wisdom of an object to -1.


assemble

   nop %actor.assemble(123)%

If the inventory of actor holds the ingredients of the assembly, then they are replaced by object 123.


assemblycheck

   %actor.assemblycheck(123)%

Returns 1 if actor has the ingredients to assemble object 123.


body

   %actor.body%

Returns all extra body positions.

   nop %player.body(crest)%

Toggles the extra body position crest.


bodycheck

   %player.bodycheck(wield)

Returns 1 if player has the body position wield.

   %player.bodycheck(crest)

Returns 1 if player has the extra body position crest (mobs have all body positions).