from compiler import *
register_plugin(__name__)
slot_party_struct_type = 0
slot_party_struct_count = 1
slot_party_struct_start = 2
slot_party_struct_end = 3
slot_party_struct_items = 4 # Actual items are stored starting from this slot
struct_type_set = 0
struct_type_list = 1
struct_type_ordered_list = 2
struct_type_stack = 3
struct_type_queue = 4
# This will make these values accessible to the rest of module system
export_plugin_globals(
struct_type_set = struct_type_set,
struct_type_list = struct_type_list,
struct_type_ordered_list = struct_type_ordered_list,
struct_type_stack = struct_type_stack,
struct_type_queue = struct_type_queue,
)
map_icons = [
("data_structure", mcn_no_shadow, "battle_track", 1.0, 0),
]
party_templates = [
("data_structure", "{!}", icon.data_structure|pf_hide_defenders|pf_is_static|pf_no_label|pf_disabled, 0, fac.no_faction, 0, []),
]
def struct_create(destination, struct_type = struct_type_set):
return [
(assign, l._cached_, reg0),
(spawn_around_party, p.temp_party, pt.data_structure),
(party_set_slot, reg0, slot_party_struct_type, struct_type),
(party_set_slot, reg0, slot_party_struct_count, 0),
(party_set_slot, reg0, slot_party_struct_start, -1),
(party_set_slot, reg0, slot_party_struct_end, -1),
(assign, destination, reg0),
(assign, reg0, l._cached_),
]
def struct_destroy(struct_id):
return [
(remove_party, struct_id),
]
def struct_set_name(struct_id, new_name):
return [
(party_set_name, struct_id, new_name),
]
def str_store_struct_name(destination, struct_id):
return [
(str_store_party_name, destination, struct_id),
]
extend_syntax(struct_create)
extend_syntax(struct_destroy)
extend_syntax(struct_set_name)
extend_syntax(str_store_struct_name)
# TEST CODE
simple_triggers = [
(0, [
(key_clicked, key_k),
(map_free),
(struct_create, ":tmp"),
(struct_set_name, ":tmp", "@Test Struct Name"),
(str_store_struct_name, s1, ":tmp"),
(struct_destroy, ":tmp"),
(display_message, "@Test successful. Struct name was `{s1}`."),
]),
]