哇噢星球

 找回密码
 申请注册
搜索
热搜: 地形 技能 Lua

YDWE自带Lua教程第五课:存读与使用物编数据

[复制链接]
皇家骑士 发表于 2019-5-26 13:35:33 | 显示全部楼层 |阅读模式
[Jass] 纯文本查看 复制代码
// 第五课

// 这次就不多说了

<?
    local slk = require 'slk'
?>

#include "YDWEBase.j"

library Test initializer Init requires YDWEBase
    globals
        private gamecache SLK_GC = InitGameCache("SLK_GC")
    endglobals
    
    private function PickupItem takes nothing returns nothing
        call DisplayTextToPlayer(Player(0), 0, 0, "你拾取的物品的价格为:" + I2S(GetStoredInteger(SLK_GC, YDWEId2S(GetItemTypeId(GetManipulatedItem())), "goldcost")))
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerUnitEventSimple(t, Player(0), EVENT_PLAYER_UNIT_PICKUP_ITEM)
        call TriggerAddAction(t, function PickupItem)
        set t = null
        
        <?
            for i = 1, 10 do
                local id = slk.item.modt:new('马甲物品'..i)
                slk.item[id].goldcost = i * 10000
            end
        ?>
        
        set SLK_GC = InitGameCache("SLK_GC")

        <?
            for id, obj in pairs(slk.item) do
                local goldcost = obj.goldcost
                if goldcost ~= '' then
        ?>
                    call StoreInteger(SLK_GC, "<?=id?>", "goldcost", <?=goldcost?>)
        <?
               end
           end
        ?>
        
    endfunction
endlibrary

回复

使用道具 举报

Archiver|手机版|小黑屋|哇噢星球  

GMT+8, 2019-6-25 05:40 , Processed in 0.029135 second(s), 13 queries , File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表