22 KiB
End Of Eden Lua Docs
Index
- Game Constants
- Utility
- Styling
- Logging
- Audio
- Game State
- Actor Operations
- Artifact Operations
- Status Effect Operations
- Card Operations
- Damage & Heal
- Player Operations
- Merchant Operations
- Random Utility
- Content Registry
Game Constants
General game constants.
Globals
DECAY_ALL
Status effect decays by all stacks per turn.
DECAY_NONE
Status effect never decays.
DECAY_ONE
Status effect decays by 1 stack per turn.
GAME_STATE_EVENT
Represents the event game state.
GAME_STATE_FIGHT
Represents the fight game state.
GAME_STATE_MERCHANT
Represents the merchant game state.
GAME_STATE_RANDOM
Represents the random game state in which the active story teller will decide what happens next.
PLAYER_ID
Player actor id for use in functions where the guid is needed, for example: deal_damage(PLAYER_ID, enemy_id, 10).
Functions
None
Utility
General game constants.
Globals
None
Functions
fetch
Fetches a value from the persistent store
Signature:
fetch(key : String) -> Any
guid
returns a new random guid.
Signature:
guid() -> String
store
Stores a persistent value for this run that will be restored after a save load. Can store any lua basic value or table.
Signature:
store(key : String, value : Any) -> None
Styling
Helper functions for text styling.
Globals
None
Functions
text_bg
Makes the text background colored. Takes hex values like #ff0000.
Signature:
text_bg(color : String, value) -> String
text_bold
Makes the text bold.
Signature:
text_bold(value) -> String
text_color
Makes the text foreground colored. Takes hex values like #ff0000.
Signature:
text_color(color : String, value) -> String
text_italic
Makes the text italic.
Signature:
text_italic(value) -> String
text_underline
Makes the text underlined.
Signature:
text_underline(value) -> String
Logging
Various logging functions.
Globals
None
Functions
log_d
Log at danger level to player log.
Signature:
log_d(value) -> None
log_i
Log at information level to player log.
Signature:
log_i(value) -> None
log_s
Log at success level to player log.
Signature:
log_s(value) -> None
log_w
Log at warning level to player log.
Signature:
log_w(value) -> None
print
Log to session log.
Signature:
print(value, value, value...) -> None
Audio
Audio helper functions.
Globals
None
Functions
play_audio
Plays a sound effect. If you want to play button.mp3 you call play_audio("button").
Signature:
play_audio(sound : String) -> None
play_music
Start a song for the background loop. If you want to play song.mp3 you call play_music("song").
Signature:
play_music(sound : String) -> None
Game State
Functions that modify the general game state.
Globals
None
Functions
get_event_history
Gets the ids of all the encountered events in the order of occurrence.
Signature:
get_event_history() -> Array
get_fight
Gets the fight state. This contains the player hand, used, exhausted and round information.
Signature:
get_fight() -> Table
get_fight_round
Gets the number of stages cleared.
Signature:
get_fight_round() -> Number
had_event
Checks if the event happened at least once.
Signature:
had_event(eventId : String) -> Bool
had_events
Checks if all the events happened at least once.
Signature:
had_events(eventIds : Array) -> Bool
had_events_any
Checks if any of the events happened at least once.
Signature:
had_events_any(eventIds : Array) -> Bool
set_event
Set event by id.
Signature:
set_event(eventId : String) -> None
set_fight_description
Set the current fight description. This will be shown on the top right in the game.
Signature:
set_fight_description(desc : String) -> None
set_game_state
Set the current game state. See globals.
Signature:
set_game_state(state : String) -> None
Actor Operations
Functions that modify or access the actors. Actors are either the player or enemies.
Globals
None
Functions
actor_add_hp
Increases the hp value of a actor by a number. Can be negative value to decrease it. This won't trigger any on_damage callbacks
Signature:
actor_add_hp(guid : String, amount : Number) -> None
actor_add_max_hp
Increases the max hp value of a actor by a number. Can be negative value to decrease it.
Signature:
actor_add_max_hp(guid : String, amount : Number) -> None
add_actor_by_enemy
Creates a new enemy fighting against the player. Example add_actor_by_enemy("RUST_MITE").
Signature:
add_actor_by_enemy(enemyId : String) -> None
get_actor
Get a actor by guid.
Signature:
get_actor(guid : String) -> Table
get_opponent_by_index
Get opponent (actor) by index of a certain actor. get_opponent_by_index(PLAYER_ID, 2) would return the second alive opponent of the player.
Signature:
get_opponent_by_index(guid : String, index : Number) -> Table
get_opponent_count
Get the number of opponents (actors) of a certain actor. get_opponent_count(PLAYER_ID) would return 2 if the player had 2 alive enemies.
Signature:
get_opponent_count(guid : String) -> Table
get_opponent_guids
Get the guids of opponents (actors) of a certain actor. If the player had 2 enemies, get_opponent_guids(PLAYER_ID) would return a table with 2 strings containing the guids of these actors.
Signature:
get_opponent_guids(guid : String) -> Table
get_player
Get the player actor. Equivalent to get_actor(PLAYER_ID)
Signature:
get_player() -> Table
remove_actor
Deletes a actor by id.
Signature:
remove_actor(guid : String) -> None
Artifact Operations
Functions that modify or access the artifacts.
Globals
None
Functions
get_artifact
Returns the artifact definition. Can take either a guid or a typeId. If it's a guid it will fetch the type behind the instance.
Signature:
get_artifact(id : String) -> Table
get_artifact_instance
Returns the artifact instance by guid.
Signature:
get_artifact_instance(guid : String) -> None
get_random_artifact_type
Returns a random type id given a max gold price.
Signature:
get_random_artifact_type(maxGold : Number) -> None
give_artifact
Gives a actor a artifact. Returns the guid of the newly created artifact.
Signature:
give_artifact(typeId : String, actor : String) -> String
remove_artifact
Removes a artifact.
Signature:
remove_artifact(guid : String) -> None
Status Effect Operations
Functions that modify or access the status effects.
Globals
None
Functions
add_status_effect_stacks
Adds to the stack count of a status effect. Negative values are also allowed.
Signature:
add_status_effect_stacks(guid : String, count : Number) -> None
get_actor_status_effects
Returns the guids of all status effects that belong to a actor.
Signature:
get_actor_status_effects(actorId : String) -> Array
get_status_effect
Returns the status effect definition. Can take either a guid or a typeId. If it's a guid it will fetch the type behind the instance.
Signature:
get_status_effect(id : String) -> Table
get_status_effect_instance
Returns the status effect instance.
Signature:
get_status_effect_instance(effectGuid : String) -> Table
give_status_effect
Gives a status effect to a actor. If count is not specified a stack of 1 is applied.
Signature:
give_status_effect(typeId : String, actorGuid : String, (optional) count : Number) -> None
remove_status_effect
Removes a status effect.
Signature:
remove_status_effect(guid : String) -> None
set_status_effect_stacks
Sets the stack count of a status effect by guid.
Signature:
set_status_effect_stacks(guid : String, count : Number) -> None
Card Operations
Functions that modify or access the cards.
Globals
None
Functions
cast_card
Tries to cast a card with a guid and optional target. If the cast isn't successful returns false.
Signature:
cast_card(cardGuid : String, (optional) targetActorGuid : String) -> Bool
get_card
Returns the card type definition. Can take either a guid or a typeId. If it's a guid it will fetch the type behind the instance.
Signature:
get_card(id : String) -> Table
get_card_instance
Returns the instance object of a card.
Signature:
get_card_instance(cardGuid : String) -> Table
get_cards
Returns all the card guids from the given actor.
Signature:
get_cards(actorGuid : String) -> Array
give_card
Gives a card.
Signature:
give_card(cardTypeId : String, ownerActorId : String) -> String
remove_card
Removes a card.
Signature:
remove_card(cardGuid : String) -> None
upgrade_card
Upgrade a card without paying for it.
Signature:
upgrade_card(cardGuid : String) -> Bool
upgrade_random_card
Upgrade a random card without paying for it.
Signature:
upgrade_random_card(actorGuid : String) -> Bool
Damage & Heal
Functions that deal damage or heal.
Globals
None
Functions
deal_damage
Deal damage to a enemy from one source. If flat is true the damage can't be modified by status effects or artifacts.
Signature:
deal_damage(source : String, target : String, damage : Number, flat : Bool) -> None
deal_damage_multi
Deal damage to multiple enemies from one source. If flat is true the damage can't be modified by status effects or artifacts.
Signature:
deal_damage_multi(source : String, targets : Array, damage : Number, flat : Bool) -> None
heal
Heals the target triggered by the source.
Signature:
heal(source : String, target : String, amount : Number) -> None
Player Operations
Functions that are related to the player.
Globals
None
Functions
give_player_gold
Gives the player gold.
Signature:
give_player_gold(amount : Number) -> None
player_buy_artifact
Let the player buy the artifact with the given id. This will deduct the price form the players gold and return true if the buy was successful.
Signature:
player_buy_artifact(artifactId : String) -> Bool
player_buy_card
Let the player buy the card with the given id. This will deduct the price form the players gold and return true if the buy was successful.
Signature:
player_buy_card(cardId : String) -> Bool
player_draw_card
Let the player draw additional cards for this turn.
Signature:
player_draw_card(amount : Number) -> None
player_give_action_points
Gives the player more action points for this turn.
Signature:
player_give_action_points(points : Number) -> None
Merchant Operations
Functions that are related to the merchant.
Globals
None
Functions
add_merchant_artifact
Adds another random artifact to the merchant
Signature:
add_merchant_artifact() -> None
add_merchant_card
Adds another random card to the merchant
Signature:
add_merchant_card() -> None
get_merchant
Returns the merchant state.
Signature:
get_merchant() -> Table
get_merchant_gold_max
Returns the maximum value of artifacts and cards that the merchant will sell. Good to scale random_card and random_artifact.
Signature:
get_merchant_gold_max() -> Number
Random Utility
Functions that help with random generation.
Globals
None
Functions
gen_face
Generates a random face.
Signature:
gen_face((optional) category : Number) -> String
random_artifact
Returns the type id of a random artifact.
Signature:
random_artifact(maxPrice : Number) -> String
random_card
Returns the type id of a random card.
Signature:
random_card(maxPrice : Number) -> String
Content Registry
These functions are used to define new content in the base game and in mods.
Globals
None
Functions
register_artifact
Registers a new artifact.
register_artifact("REPULSION_STONE",
{
name = "Repulsion Stone",
description = "For each damage taken heal for 2",
price = 100,
order = 0,
callbacks = {
on_damage = function(ctx)
if ctx.target == ctx.owner then
heal(ctx.owner, 2)
end
return nil
end,
}
}
)
Signature:
register_artifact(id : String, definition : Table) -> None
register_card
Registers a new artifact.
register_card("MELEE_HIT",
{
name = "Melee Hit",
description = "Use your bare hands to deal 5 (+3 for each upgrade) damage.",
state = function(ctx)
return "Use your bare hands to deal " .. highlight(5 + ctx.level * 3) .. " damage."
end,
max_level = 1,
color = "#2f3e46",
need_target = true,
point_cost = 1,
price = 30,
callbacks = {
on_cast = function(ctx)
deal_damage(ctx.caster, ctx.target, 5 + ctx.level * 3)
return nil
end,
}
}
)
Signature:
register_card(id : String, definition : Table) -> None
register_enemy
Registers a new artifact.
register_enemy("RUST_MITE",
{
name = "Rust Mite",
description = "Loves to eat metal.",
look = "/v\\",
color = "#e6e65a",
initial_hp = 22,
max_hp = 22,
gold = 10,
callbacks = {
on_turn = function(ctx)
if ctx.round % 4 == 0 then
give_status_effect("RITUAL", ctx.guid)
else
deal_damage(ctx.guid, PLAYER_ID, 6)
end
return nil
end
}
}
)
Signature:
register_enemy(id : String, definition : Table) -> None
register_event
Registers a new artifact.
register_event("SOME_EVENT",
{
name = "Event Name",
description = [[Flavor Text... Can include **Markdown** Syntax!]],
choices = {
{
description = "Go...",
callback = function()
-- If you return nil on_end will decide the next game state
return nil
end
},
{
description = "Other Option",
callback = function() return GAME_STATE_FIGHT end
}
},
on_enter = function()
play_music("energetic_orthogonal_expansions")
give_card("MELEE_HIT", PLAYER_ID)
give_card("MELEE_HIT", PLAYER_ID)
give_card("MELEE_HIT", PLAYER_ID)
give_card("RUPTURE", PLAYER_ID)
give_card("BLOCK", PLAYER_ID)
give_artifact(get_random_artifact_type(150), PLAYER_ID)
end,
on_end = function(choice)
-- Choice will be nil or the index of the choice taken
return GAME_STATE_RANDOM
end,
}
)
Signature:
register_event(id : String, definition : Table) -> None
register_status_effect
Registers a new artifact.
register_artifact("REPULSION_STONE",
{
name = "Repulsion Stone",
description = "For each damage taken heal for 2",
price = 100,
order = 0,
callbacks = {
on_damage = function(ctx)
if ctx.target == ctx.owner then
heal(ctx.owner, 2)
end
return nil
end,
}
}
)
Signature:
register_status_effect(id : String, definition : Table) -> None
register_story_teller
Registers a new artifact.
register_artifact("REPULSION_STONE",
{
name = "Repulsion Stone",
description = "For each damage taken heal for 2",
price = 100,
order = 0,
callbacks = {
on_damage = function(ctx)
if ctx.target == ctx.owner then
heal(ctx.owner, 2)
end
return nil
end,
}
}
)
Signature:
register_story_teller(id : String, definition : Table) -> None