【CSOL】仿对话框装置UI
--剧情.lua
if Game then
--分离参数
function splitstr_tostring(inputstr)
local t = {}
for str in string.gmatch(inputstr, "([^,]*)") do
table.insert(t, str)
end
return t
end
--读取玩家信息
function Call_Player(call)
if call then
local a=Game.GetTriggerEntity()
if a:IsPlayer() then
local p=a:ToPlayer()
return p
end
end
end
JuQingTextList={
[1]={
text={
{text="这里是哪里",time=0.2,zhuangzhi="jieladetongku"},
{text="我最后的印象里我在华尔兹大街",time=3,zhuangzhi="jieladetongku"},
{text="我遇到了一个乞讨的女孩",time=3,zhuangzhi="jieladetongku"},
{text="当我再次睁开眼睛的已经到了这里",time=3,zhuangzhi="jieladetongku"},
{text="神秘人:这里是屠宰场",time=3,zhuangzhi="shenmiren"},
{text="你是谁,谁再说话?",time=3,zhuangzhi="jieladetongku"},
{text="此时天空传来了乌鸦叫声",time=4,zhuangzhi="wuya"},
{text="",time=2},
},},
[2]={
text={
{text="神秘人:这里是哪里",time=0.2},
{text="神秘人:我最后的印象里我在华尔兹大街",time=2},
{text="神秘人:我遇到了一个乞讨的女孩",time=2},
{text="",time=2},
},},
}
local JuQingStart=false
juqingtext=Game.SyncValue:Create ("juqingtext")
--第一个参数是剧情编号
function juqing(call,arg)
if call then
local player = Call_Player(call)
local args=splitstr_tostring(arg)
JuQing_Start=true
JuQing_List=JuQingTextList[tonumber(args[1])]
JuQing_Index=1
end
end
local biaoqingcount=0
Framework.GamePlug.OnUpdate:Register(function(time)
if JuQing_Start==true then
if JuQing_List.text[JuQing_Index]~=nil then
JuQing_List.text[JuQing_Index].time=JuQing_List.text[JuQing_Index].time-0.1
if JuQing_List.text[JuQing_Index].time<=0 then
juqingtext.value=JuQing_List.text[JuQing_Index].text
if JuQing_List.text[JuQing_Index].zhuangzhi~=nil then
if biaoqingcount==0 then
Game.SetTrigger(JuQing_List.text[JuQing_Index].zhuangzhi, false)
Game.SetTrigger(JuQing_List.text[JuQing_Index].zhuangzhi, true)
biaoqingcount=1
end
end
JuQing_Index=JuQing_Index+1
biaoqingcount=0
end
else
juqingtext.value=0
end
end
end)
end
if UI then
Show_Box={}
function createbeijing()
Show_BoxList={width=700,a=255,r=0,g=0,b=0}
for i=1,70 do
Show_Box[i]=UI.Box.Create()
Show_Box[i]:Set({
x=center.x/3,
y=center.y/1.25-(i*1.5),
width=Screen.x/1.5,
height=3,
r=Show_BoxList.r+(i),
g=Show_BoxList.g+(i),
b=Show_BoxList.b+(i),
a=Show_BoxList.a+(i*2)
})
end
end
function removebeijing()
for i=1,70 do
Show_Box[i]=nil
end
end
juqingtext=UI.SyncValue.Create("juqingtext")
function juqingtext:OnSync()
if self.value~=0 then
removebeijing()
juqingtextshow=nil
collectgarbage()
createbeijing()
juqingtextshow=DrawText:Create()
juqingtextshow:Set({x=center.x/2,y=center.y/1.4,text=self.value,size=2,r=255,g=255,b=255,kerning=2})
juqingtextshow:BlinkShow(0.1)
else
removebeijing()
juqingtextshow=nil
collectgarbage()
end
end
end