– .Lottery抽卡系统
– author 957
– 版本 V1.1.0
– 更新日期 2021/12/18
– 思路
– 分为 注册功能,抽卡模块,金币收集模块 以及 查看背包金币
msg_order = {}
– 注册功能
function register(msg)
local user = getUserConf(msg.fromQQ,"user",0)
if(user == 0)then
setUserConf(msg.fromQQ,"user",1)
setUserConf(msg.fromQQ,"usergold",100)
return "{at}注册成功啦~快去抽卡叭!!"
else
return "{nick} 请勿重复注册哦!"
end
end
– 抽卡模块
function checkDaily(msg)
– 个人金币存档
local usergolds = getUserConf(msg.fromQQ,“usergold”,0)
– 卡池
local cardPool = {
“被咬了一口的绿苹果…”,
“漂亮老板娘亲自调给你的一杯被加热的绿色的并不好喝的可口可乐~”,
“一个装了猫猫的空cup~”,
“立志斩断牛子的氪晴姐姐!!”,
“半只破烂的拖鞋!”,
“一个神秘网址(然而并不能打开~)”,
}
-- 金币抽卡消费记录系统
function golds(msg)
local user_gold = usergolds
local corpus = ranint(5,40)
local user_gold = user_gold - corpus
setUserConf(msg.fromQQ,"usergold",user_gold)
return corpus
end
-- 抽卡系统
function get_goods(tab)
if(#tab==0)then return "" end
return tab[ranint(1,#tab)]
end
-- 限制每日抽卡次数
local today_time = getUserToday(msg.fromQQ,"lotterytimes",0)
if(today_time <= 10)then
return "{nick} 花费"..golds(msg).."金币抽到了"..get_goods(cardPool).."~"
else
return "{at} 今日抽卡次数已经用完啦!明天再来吧~"
end
today_time = today_time + 1
setUserToday(msg.fromQQ,"lotterytimes",today_time)
-- 最后一次抽卡进行提醒
if(today_time == 10)then
return "{at} 这是最后一次抽卡了哟~~"
end
end
– 金币收集功能写了钓鱼和打怪
function fishing(msg)
local fishlist = {“红鲤鱼”,“绿鲤鱼”,“金龙鱼”,“未知品种的不知名动物”,}
function getfish(tab)
return tab[math.floor(ranint(1,4))]
end
local usergold = getUserConf(msg.fromQQ,"usergold",0)
local fishgold = ranint(5,20)
setUserConf(msg.fromQQ,"usergold",usergold + fishgold)
return "{nick}掉到了一条"..getfish(fishlist).."获得了"..fishgold.."枚金币~"
end
function attack(msg)
local usergold = getUserConf(msg.fromQQ,“usergold”,0)
local attackgold = ranint(15,30)
setUserConf(msg.fromQQ,“usergold”,usergold + attackgold)
return “{nick}打倒了一只不知名野生奥特曼,获得了”..attackgold..“枚金币~”
end
– 查看金币余额
function check_gold(msg)
local usergolds = getUserConf(msg.fromQQ,“usergold”,0)
return “{at}您的金币余额为”..usergolds..“枚金币~”
end
– 指令
msg_order[“.register”] = “register”
msg_order[“.lottery”] = “checkDaily”
msg_order[“.checkmygold”] = “check_gold”
msg_order[“.fishing”] = “fishing”
msg_order[“.attack”] = “attack”
粗略看了一点lua的简单语法,参考大佬们写的脚本试着写的简单小游戏,写的有些繁琐,希望大佬们提一些优化建议~加油加油加油!