Skip to content
GutenYe edited this page Aug 15, 2012 · 4 revisions

Wiki教程Lua扩展

Lua扩展

目前有两种语法.

语法1

  tuxi = sgs.CreateViewAsSkill{
    name = "tuxi",
    n = 0,

    view_as = function(self, cards)
      ..
    end
  }

语法2

  zhangliao == sgs.General(extensions, "zhangliao", "wei", "4", true)

  Tuxi = class("Tuxi", ViewAsSkill)

    function Tuxi:initialize()
      ViewAsSkill.initialize(self)
      self.name = "tuxi"
      self.n = 0
    end

    function Tuxi:view_as(skill, cards)
      ...
    end

  tuxi = Tuxi:create() -- need at file scope

  TuxiCard = class("TuxiCard", SkillCard) 

    function TuxiCard:initialize()
      SkillCard.initialize(self)
      self.name = "tuxi"
      self.target_fixed = false
    end,

    function TuxiCard:on_effect(card, effect)
      ...
    end

  tuxi_card = TuxiCard:create() -- need at file scope

  zhangliao:addSkill(tuxi)

用Github模式来开发扩展

文件结构

  youka/
    extensions/  # 开发的文件夹
      youka.lua
      youka/
        caocao.lua  # 每个武将1个文件.
        caocao.ai.lua
    dist/   # 发布的文件夹.
      images/
      audios/
      extensions/  # 自动生成.

发布youka包

   $ bundle exec rakep build
   # 生成1个 youka/dist/extensions/youka.lua 单一文件
   # 现在只要发布 youka/dist/ 这个文件夹就好了.

可以参考 https://github.com/GutenYe/qsgs-extensions/tree/master/weihou 这个例子。

Clone this wiki locally