From e74ceca80f32ee46e23e442d34fd2652318c9468 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 3 Sep 2022 09:23:17 +0000 Subject: [PATCH] update slate[no ci] --- docs/index.html | 97 +++++++++++++++++++++++++++++++++++++++++++++++-- docs/light.html | 97 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 188 insertions(+), 6 deletions(-) diff --git a/docs/index.html b/docs/index.html index 714c6a23d..acf52603f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1164,6 +1164,9 @@
-Search script examples for add_item_to_shop
Adds entity as shop item, has to be movable (haven't tested many)
@@ -4982,8 +4985,14 @@spawn_tree
-Search script examples for spawn_tree
nil spawn_tree(float x, float y, LAYER layer)
nil spawn_tree(float x, float y, LAYER layer, int height)
+int spawn_tree(float x, float y, LAYER layer)
int spawn_tree(float x, float y, LAYER layer, int height)
Spawns and grows a tree
+spawn_unrolled_player_rope
+++Search script examples for spawn_unrolled_player_rope
+int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture)
int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture, int max_length)
+Spawns an already unrolled rope as if created by player
String functions
add_custom_name
Search script examples for add_custom_name
@@ -6520,7 +6529,7 @@Entity related types
Ai
int whipped -How many times master has violated us +Number of times whipped by player Animation
@@ -6533,6 +6542,11 @@Animation
+ int +id ++ + @@ -6553,6 +6567,63 @@int first_tile Animation
EntityDB
+Used to store static common data for an ENT_TYPE. You can also clone entity types with the copy constructor to create new custom entities with different common properties. This tool can be helpful when messing with the animations. The default values are also listed in entities.json.
+ +++When cloning an entity type, remember to save it in the script for as long as you need it. Otherwise the memory will be freed immediately, which eventually leads to a crash when used or overwritten by other stuff:
++-- Create a special fast snake type with weird animation +special_snake = EntityDB:new(ENT_TYPE.MONS_SNAKE) +special_snake.max_speed = 1 +special_snake.acceleration = 2 +special_snake.animations[2].num_tiles = 1 + +set_post_entity_spawn(function(snake) + -- 50% chance to make snakes special + if prng:random_chance(2, PRNG_CLASS.PROCEDURAL_SPAWNS) then + -- Assign custom type + snake.type = special_snake + -- This is only really needed if types are changed during the level + snake.current_animation = special_snake.animations[2] + end +end, SPAWN_TYPE.ANY, MASK.MONSTER, ENT_TYPE.MONS_SNAKE) +
++You can also use Entity.user_data to store the custom type:
++-- Custom player who is buffed a bit every level +set_callback(function() + -- Doing this to include HH + for i,v in ipairs(get_entities_by_mask(MASK.PLAYER)) do + local player = get_entity(v) + + -- Create new custom type on the first level, based on the original type + if not player.user_data then + player.user_data = {} + player.user_data.type = EntityDB:new(player.type.id) + end + + -- Set the player entity type to the custom type every level + player.type = player.user_data.type + + -- Buff the player every subsequent level + if state.level_count > 0 then + player.type.max_speed = player.type.max_speed * 1.1 + player.type.acceleration = player.type.acceleration * 1.1 + player.type.jump = player.type.jump * 1.1 + end + end +end, ON.POST_LEVEL_GENERATION) +
++Illegal bad example, don't do this:
+set_callback(function() + -- Nobody owns the new type and the memory is freed immediately, eventually leading to a crash + players[1].type = EntityDB:new(players[1].type) + players[1].type.max_speed = 2 +end, ON.POST_LEVEL_GENERATION) +
Type @@ -6561,6 +6632,16 @@EntityDB
+ +EntityDB +new(EntityDB other) ++ + +EntityDB +new(ENT_TYPE) ++ ENT_TYPE id @@ -15715,6 +15796,11 @@ Entity
+ nil +set_enable_turning(bool enabled) ++ + @@ -19935,6 +20021,11 @@nil liberate_from_shop() CustomMovableBehavior
+ +VanillaMovableBehavior +base_behavior ++ nil set_force_state(function force_state) Set the diff --git a/docs/light.html b/docs/light.html index 16a708b7c..8f82e8a15 100644 --- a/docs/light.html +++ b/docs/light.html @@ -1164,6 +1164,9 @@force_state
function of aCustomMovableBehavior
, this will be called every frame when
the movable is updated. If anforce_state
is already set it will be overridden. The signature
of the function isbool force_state(movable, base_fun)
, when the function returnstrue
the movable will
enter this behavior. If no base behavior is setbase_fun
will benil
.spawn_tree ++ spawn_unrolled_player_rope + @@ -4720,7 +4723,7 @@ Shop functions
add_item_to
-Search script examples for add_item_to_shop
nil add_item_to_shop(int item_uid, int shop_owner)
+nil add_item_to_shop(int item_uid, int shop_owner_uid)
Adds entity as shop item, has to be movable (haven't tested many)
change_diceshop_prizes
@@ -4982,8 +4985,14 @@spawn_tree
-Search script examples for spawn_tree
nil spawn_tree(float x, float y, LAYER layer)
nil spawn_tree(float x, float y, LAYER layer, int height)
+int spawn_tree(float x, float y, LAYER layer)
int spawn_tree(float x, float y, LAYER layer, int height)
Spawns and grows a tree
+spawn_unrolled_player_rope
+++Search script examples for spawn_unrolled_player_rope
+int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture)
int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture, int max_length)
+Spawns an already unrolled rope as if created by player
String functions
add_custom_name
Search script examples for add_custom_name
@@ -6520,7 +6529,7 @@Entity related types
Ai
int whipped -How many times master has violated us +Number of times whipped by player Animation
@@ -6533,6 +6542,11 @@Animation
+ int +id ++ + @@ -6553,6 +6567,63 @@int first_tile Animation
EntityDB
+Used to store static common data for an ENT_TYPE. You can also clone entity types with the copy constructor to create new custom entities with different common properties. This tool can be helpful when messing with the animations. The default values are also listed in entities.json.
+ +++When cloning an entity type, remember to save it in the script for as long as you need it. Otherwise the memory will be freed immediately, which eventually leads to a crash when used or overwritten by other stuff:
++-- Create a special fast snake type with weird animation +special_snake = EntityDB:new(ENT_TYPE.MONS_SNAKE) +special_snake.max_speed = 1 +special_snake.acceleration = 2 +special_snake.animations[2].num_tiles = 1 + +set_post_entity_spawn(function(snake) + -- 50% chance to make snakes special + if prng:random_chance(2, PRNG_CLASS.PROCEDURAL_SPAWNS) then + -- Assign custom type + snake.type = special_snake + -- This is only really needed if types are changed during the level + snake.current_animation = special_snake.animations[2] + end +end, SPAWN_TYPE.ANY, MASK.MONSTER, ENT_TYPE.MONS_SNAKE) +
++You can also use Entity.user_data to store the custom type:
++-- Custom player who is buffed a bit every level +set_callback(function() + -- Doing this to include HH + for i,v in ipairs(get_entities_by_mask(MASK.PLAYER)) do + local player = get_entity(v) + + -- Create new custom type on the first level, based on the original type + if not player.user_data then + player.user_data = {} + player.user_data.type = EntityDB:new(player.type.id) + end + + -- Set the player entity type to the custom type every level + player.type = player.user_data.type + + -- Buff the player every subsequent level + if state.level_count > 0 then + player.type.max_speed = player.type.max_speed * 1.1 + player.type.acceleration = player.type.acceleration * 1.1 + player.type.jump = player.type.jump * 1.1 + end + end +end, ON.POST_LEVEL_GENERATION) +
++Illegal bad example, don't do this:
+set_callback(function() + -- Nobody owns the new type and the memory is freed immediately, eventually leading to a crash + players[1].type = EntityDB:new(players[1].type) + players[1].type.max_speed = 2 +end, ON.POST_LEVEL_GENERATION) +
Type @@ -6561,6 +6632,16 @@EntityDB
+ +EntityDB +new(EntityDB other) ++ + +EntityDB +new(ENT_TYPE) ++ ENT_TYPE id @@ -15715,6 +15796,11 @@ Entity
+ nil +set_enable_turning(bool enabled) ++ + @@ -19935,6 +20021,11 @@nil liberate_from_shop() CustomMovableBehavior
+ +VanillaMovableBehavior +base_behavior ++ nil set_force_state(function force_state) Set the force_state
function of aCustomMovableBehavior
, this will be called every frame when
the movable is updated. If anforce_state
is already set it will be overridden. The signature
of the function isbool force_state(movable, base_fun)
, when the function returnstrue
the movable will
enter this behavior. If no base behavior is setbase_fun
will benil
.