-           .     ,    runtime-    ,    .  ,     arena.lua,          ,   . -    ,         ,     ,    .  ,        ,   , ,  ,       ,   .


0)  :

1.3)

-       ,      ,    . (  SayNt  Serimon!!!)
-    KBMaster.PPEDEF,        ""  . (.  3.5)
-        .
-          ,    . (.  5.1)
-    Aux. (.  5.2)
-   Mod:replace,       Mod:delete.    ,   Mod:insert,   ,      .
- Mod:insert_start_chunk  Mod:insert_end_chunk .  Mod:insert ,      , .
-   -,    .   byAlex!

1.2)

-  ,        .
-    (  16) -     ,     .  -       .
-       KBMaster.   ( 60 )   .
-   .

1.1)

-  ,       .
-     -   .    frontend-,         .
-           ,    ,    .
-  runtime-             -,   string: ...
-    \ .
-  debug-.          ,    -   kfs-  -      .        testscript.     - KBM_log.txt.        (   KBMaster).


1)   :

    KBMaster_base_1.0_for_1.7.kfs   data/mods    .    ,    - . -     ,    ,         .  ,      ,  -   ,    .       KBMaster_base_1.0_for_1.7.kfs  data/mods.

 ,         "KBMaster<3>: __delete range intersect conflict:"  "KBMaster<15>: insertion priority conflict:", ,    ,  , .        .


2)  :

     " " ,   .  :

-      "  ". [ tav  ]
	       1.6.    .
	   12  .
	      .
	    ,     (:   ,  ,     )
	Alt+     -    .

-                .
-      . [ spamm]
-     [Serimon]


3.1)     (  ,     ,    ):

 ,       (   )    :

1)   - :

     (, arena.lua) -    - ,  .     (  ),        -  ,     . ,    .          (       , , SciTE),     ,     .      ,      -     N,       .      .

2)  ,    ,  ,      :

  (,    ):

local i = 1
while i < 5 do
  Attack.arena_text("hello world!")
  i = i + 1
end

 :

local string_name =
[[local i = 1
while i < 5 do
  Attack.arena_text("hello world!")
  i = i + 1
end
]] --    

3)      :

local Mod = KBMaster.newmod (mod_name[,version])     (Mod)   ,   mod_name - , ,    ,  ,   .      .       ( ),    "1.0".

,  ,   ,   insert:

Mod:insert (script_file,code,index) --  script_file -  ,     ,  . Code - ,     ,  code = "Attack.arena_text('hello world!')".  -     ,      .  ,          ,   .

     delete:

Mod:delete (script_file,index[,index_end]) -- index -    ,   index_end ,       ,      index  index_end.

      ,   ,    load ():

Mod:load ()

:

,   -   useless.lua   :

1: function reprint ()
2:   local word = "hello world"
3:   print (word)
4: end

   4 . ,       ,    .      ,      4.  - :

local modstring =
[[print ("hello again")
]]

local Mod = KBMaster.newmod ("my_new_mod")
Mod:insert ("useless",modstring,4)
Mod:load ()

 .        word,   .      :

local Replace_Mod = KBMaster.newmod ("my_new_mod_2")
Replace_Mod:delete ("useless",2)
Replace_Mod:insert ("useless","local word = 'goodbye cruel world'",2)
Replace_Mod:load ()

  reprint    "goodbye cruel world".  ,          , -   . ,       ,     -.

  -   (  ,   -):

<1>:       .
<2>:    ,      .
<3>:                (  ).
<4>:       (     ).
<5>:      - (    -  ,  ,   ,       KBMaster.newmod)
<6>:    .        .
<7>:    .
<13>:   .
<8>,<10>,<11>,<12>:     insert  delete.
<9>:        -.
<15>:    (   ).

       -  hello_world.kfs.       ,    .  -       .


3.2)     :

   . -,       ,       do ... end,       local.    do ... end  if KBMaster then ... end.       ,        -.     -   ,          ,   if KBMaster then ...  else error ( ) end.             ,    (,     ,    ).

    -   , :

Mod:insert_start_chunk
Mod:insert_end_chunk

  chunk?  -  .     ,     end. ,

for i=1,5 do
...
end

  ,     if ... then  .   ,       ,       Mod:insert. ,     ,    . :

useless.lua:

1: print "hello"
2:

Mod:insert ("useless","for i=1,3 do",1)
Mod:insert ("useless","end",2)

  :

1: for i=1,3 do
2: print "hello"
3: end
4:

      ,       , :

Mod:insert ("useless",'print "world"',2)

,    ,       :

1: for i=1,3 do
2: print "hello"
3: print "world"
4: end
5:

1: for i=1,3 do
2: print "hello"
3: end
4: print "world"
5:

      ,  ,   ,         .

   ,     .

Mod:insert_start_chunk      -        .
Mod:insert_end_chunk    

   :

Mod1:insert_start_chunk ("useless","for i=1,3 do",1)
Mod1:insert_end_chunk ("useless","end",2)

Mod2:insert ("useless",'print "world"',2)

  :

1: for i=1,3 do
2: print "hello"
3: end
4: print "world"
5:

     , , .   ()        ,         -    ,  -  .         ,   ,      . ,       (   - end)     ,  Mod:insert.


3.3)    -:

KBMaster.newmod (mod_name[, version]) --    ""    mod_name    version (  "1.0"),     :
Mod:delete (sfile, index[, index_end]) --   sfile   index  index_end.
Mod:insert (sfile, code, index) --   sfile   index  code.
Mod:insert_start_chunk (sfile, code, index) --       . //
Mod:insert_end_chunk (sfile, code, index) --       .   //
Mod:load () --        .
Mod:replace (sfile, code, index[, index_end]) --    index  index_end  sfile   code.


3.4)       :

   .      KBMaster.newmod,     mod_name. ,  mod_name="my_new_mod" (      , ,            ,   ). , -  -  ( ,         "rus_")     :

mod_my_new_mod_name=     
mod_my_new_mod_author= 

,         (    ,    ),      ,         .     -  "" :

if KBMaster then
  local Mod = KBMaster.newmod (mod_name,version)
  Mod:load () --  ,     .
end

    .lng      !


3.5)  :

     Mod:insert   ,    ,  ,      .     KBMaster.PREDEF.  ,  , ,   on_round_start,    :

local Mod = KBMaster.newmod ("my_mod")
  Mod:insert ("arena", "print 'hello world'", KBMaster.PREDEF.arena_on_round_start)
Mod:load ()

       :

arena.lua:
1) arena_on_combat_start  --   375,       
2) arena_on_round_start   --   532,     
3) arena_ai_attack_solver --  1868,    ,     ,       .
logic_hero.lua:
4) logic_generation_hero  --   343,    ,     ,     .
5) logic_regular_script   --   150,         /.


4)    :

 -     .      ,   - config.txt, items.txt, itextures.dat  ignorecp.txt.  ,       (!!!     ,     ,  ) ,  :
1)       www.kingsbounty.ru.    101 (,     "")    200.       .
2)     NNN.mod,  NNN -  ,      ,    .
3)   - (   ,     items.txt  config.txt):

items.txt   -   master_itm_NNN.txt
config.txt  -   master_cfg_NNN.txt
itextures.dat - master_tex_NNN.txt(!)
ignorecp.txt  - master_icp_NNN.txt

,      texNNN.dds (      101,    001).

,            config.txt,  items.txt.          :

spells.txt
specials.txt
boss.txt
effects.txt
wifes.txt
items_quest.txt
items_monster.txt
params.txt
special_params.txt

 master_itm_NNN.txt,         :

hero.txt
arena.txt
logic.txt

 master_cfg_NNN.txt.


5.1)   -   :

KBMaster       string,      ,      .  ,       ,               .

string.linesub (str, index[, index2]) --   string.sub,     ,    (  ).       .
string.insert_l (str, index, ins) --    str  ins     index.
string.insert_c (str, index, ins) --    str  ins     index.
string.insert_lc (str, index_l, index_c, ins) --    str  ins   index_c    index_l.
string.delete_l (str, index[, index2]) --      index  index2.   index2 = index.
string.delete_c (str, index[, index2]) --      index  index2.   index2 = index.
string.delete_lc (str, index_l, index_c[, index_l2[, index_c2]]) --      index_c   index_l  index_c2   index_l2.    index_l2,   .   index_l2    index_c2,     index_l2.
string.replace_l (str, index, index2, ins) --    insert_l (str, index, ins)  delete_l (str, index, index2).
string.replace_c (str, index, index2, ins) --   .
string.replace_lc (str, index_l, index_c, index_l2, index_c2, ins) --  .
string.ctolc (str, c) --      ,   ,    ,      .
string.lctoc (str, l, c) --    ,    ,      ,      .
string.getmap (str) --       str.     ,    -         .     .


5.2)   - King's Bounty Auxilary Library:

     Aux,          .         ,    ,      .  ,   ,    ,     ,      .

Aux.StrictTypeFunc (func, N, ...) --     -,       ,  .  ,           .  ,    .
Aux.Config (...) --       ,      "/". Aux.Config ("familiar_beh", "skills", "commander", "rank")     "familiar_beh/skills/commander/rank".   ,    .
Aux.ConfigN (...) --   ,   .
Aux.ReadGameIni (key) --   game.ini  ,    ,    ,     .    key  "language",  "rus".
Aux.ReadAppIni (key) --||-- app.ini
Aux.ReadDefaultIni (key) --||-- default.ini
Aux.ErrorLog (text) --       ,    .
Aux.ErrorBox (text) --          .
Aux.Error (text) --    .   .
Aux.MsgBox (text) --     Game.InvokeMsgBox, ,   ,      nil.
Aux.NewTimer ([countdown]) --   - ,      - 0.     ,     .   countdown,    -        ( ),  -   .
Aux.FlattenTable (table) --    ,  , ,    .          (,   ),  .   ,      ,          .
Aux.UnflattenTable (flattened_string) --    ,    .
Aux.GameVersion ([get_build]) --    .     ,   ,   .
Aux.MsgCast (uid, messages) --    ,   - ,   -  .  ,       uid. uid - .
Aux.MsgBroadCast (messages) --    ,   - ,   -  .   .
Aux.MsgMultiCast (messages, ...) --  ,      .
Aux.MsgReceive ([uid]) --     uid    .    .

  :
function on_round_start (round, tend) --      
  ...
  Aux.MsgBroadCast {arena_round = round} --      ,     
  Aux.MsgCast ("this", {first_round = (round == 1)}) --   this   ,    
  ..
end

function unit_regeneration () -- -   

  local round = Aux.MsgReceive().arena_round -  ,  ,   
  ...
  
end

Aux.MsgReceive().first_round >>> nil --      
Aux.MsgReceive("this").first_round >>> true  false --  ,   

   ,     ,      (,     -      ,       ,  ,      ),      ,       .         ,    -  -      .

  1.3 -     -     Aux.MsgReceive().arena_round     .



 ,          kingsbounty.ru.
      :

ZakkeR
SayNt
Serimon
byAlex
spamm

  !

  aka NyRe.