DocsMegalithLanguage

Options, traits and zones

Settings hosts can change, trait sets and zones live in the mode header, and the script reads them by number. megalo-zone-traits.rmeg has one of each:

Part of megalo-zone-traits.rmeg
--[=[ mode
name = "Zone Traits"

[logic.options]
goal = { value = 30, min = 1, max = 100 }
interval = { value = 1, min = 1, max = 10 }

[logic.objects.hill]
source = { kind = "zone" }
position = [0, 0, 0]
label = "objective"
shape = { kind = "sphere", radius = 8 }

[[logic.megalo_traits]]
speed = 7
aura = 4
]=]
  • Options: script_option[0] is the first option in alphabetical order, so here goal is 0 and interval is 1; an option added earlier in the alphabet moves the others up. A name is up to 32 letters, digits and underscores. A mode can declare 32, and the script reads the first 16 by number, as whole numbers, so keep ranges whole. Hosts change them under Game Options → Slayer Rules → Custom Mode Options, or the rules of the game type the mode plays.
  • Traits: script_traits[0] is the first set, up to 16 sets. Values are choices, not percentages: see the trait values. Apply the set on every tick the player should have it: traits last one tick, over those of their class. Several sets merge nonzero choices in call order; 0 leaves what's there.
  • Zones: loop over them by label and test current_object.shape_contains(current_player.biped). A zone is invisible and has no collision. Move one with set_position, as Zone Control does, to find its place at run time. Before you play Zone Traits, set the hill's position to a place on your map: in Forge, fly the monitor there and read Where it is on the Forge menu's Map tab.
Part of megalo-zone-traits.rmeg
for each object with label "objective" do
   for each player do
      if current_player.is_not_respawning() then
         if current_object.shape_contains(current_player.biped) then
            current_player.apply_traits(script_traits[0])
         end
      end
   end
end