用 script 编写 远程传送装置 + 详细中文注释 ----- Part 2
最近陷入MO7不能自拔,现在终于有时间先把这个坑填了{:3_143:}上一篇Part 1我们写了 远程传送终端 的script,这一篇我们写掉 远程传送装置 的script。由于有了上一篇的基础,本文大家应该能好理解多了
以下内容是MiniHideout里的 远程传送装置 script,本文将涉及到多条message选项与getbuttonpressed值的互动
==============
红色字体表示重要注释
蓝色字体强调命令
==============
INT MenuLevel
INT Button
INT TeleportEND
INT TeleportSTART
FLOAT Timer
Begin OnFire Player \ 开火时
playsound NPCSecuritronTelemetry \ 播放声音
Set MenuLevel to 1 \ 设置1级菜单
Set Timer to .5 \ 设置浮动时间点 0.5秒
END
Begin GameMode \ 游戏模式开始
If Player.GetEquipped MHTeleportDevice \ 如果玩家装备了MHTeleportDevice这件武器
(GetEquipped,装备了某样东西,武器或者装备都可以)
If MenuLevel == 1 \ 如果是1级菜单
;===Main Menu===
showmessage MHTeleportDeviceMenu01 \ 显示MHTeleportDeviceMenu01 这条message
Set MenuLevel to 2 \ 设置为2级菜单
Return \ 返回
elseif MenuLevel == 2 \ 此外,在2级菜单的情况下
Set Button to getButtonPressed \ 令button等于getbuttonpressed值
If Button == -1
Return
elseif Button == 0 \ message第一个选项
;===Teleport Home=== \ 直接传送回家
Set TeleportLocation to MHTeleportHomeMarkerREF \ 定义TeleportLocation为MHTeleportHomeMarker
Playsound WPNEuclidFinderUplink
Set TeleportSTART to 1 \ 设置TeleportSTART为1(表示传送开始)
Set MenuLevel to 0 \ 设置0级菜单(按照整篇script定义,则什么菜单也不显示)
Return
elseif Button == 1 \ message第二个选项
;===Teleport Custom Locations=== \ 传送到自定义位置
Showmessage MHTeleportCustomLocations \ 显示MHTeleportCustomLocations 这条message
Set MenuLevel to 3 \ 设置3级菜单
elseif Button == 2 \ message第三个选项
;===Set Custom Locations=== \ 设定自定义位置
Showmessage MHTeleportCustomLocationsSetup \ 显示MHTeleportCustomLocationsSetup这条message
Set MenuLevel to 4 \ 设置4级菜单
else
Set MenuLevel to 0 \ 设置0级菜单(全部到此结束,退出菜单)
Return
endif
elseif MenuLevel == 3 \ 此外,在3级菜单的情况下
;===Teleport Custom Locations===
Set Button to GetButtonPressed \ 令button等于getbuttonpressed值
If Button == -1
Return
elseif Button == 0 \ message第一个选项
Set TeleportSTART to 1 \ 设置TeleportSTART为1(表示传送开始)
Set TeleportLocation to MHCustomTeleMarkerREF01 \ 定义TeleportLocation为MHCustomTeleMarkerREF01
Playsound WPNEuclidFinderUplink
Set MenuLevel to 0 \ 设置0级菜单(全部到此结束)
Return
elseif Button == 1 \ message第二个选项
Set TeleportSTART to 1 \ 设置TeleportSTART为1(表示传送开始)
Set TeleportLocation to MHCustomTeleMarkerREF02 \ 定义TeleportLocation为MHCustomTeleMarkerREF02
Playsound WPNEuclidFinderUplink
Set MenuLevel to 0 \ 设置0级菜单(全部到此结束)
Return
elseif Button == 2 \ message第三个选项
Set TeleportSTART to 1 \ 设置TeleportSTART为1(表示传送开始)
Set TeleportLocation to MHCustomTeleMarkerREF03 \ 定义TeleportLocation为MHCustomTeleMarkerREF03
Playsound WPNEuclidFinderUplink
Set MenuLevel to 0 \ 设置0级菜单(全部到此结束)
Return
endif
showmessage MHTeleportDeviceMenu01 \ 显示MHTeleportDeviceMenu01 这条message
Set MenuLevel to 2 \ 设置2级菜单
(这里相当于从下一级子菜单返回上一级主菜单,这条设置很重要,否则会直接退出菜单)
elseif MenuLevel == 4 \ 此外,在4级菜单的情况下
;===Custom Locations Setup=== \ 自定义地点设置
Set Button to GetButtonPressed
If Button == -1
Return
elseif Button == 0
MHCustomTeleMarkerREF01.moveto Player \ 将MHCustomTeleMarkerREF01移动到玩家所在地
(这就是如何自定义地点的方法)
elseif Button == 1
MHCustomTeleMarkerREF02.moveto Player \ 将MHCustomTeleMarkerREF02移动到玩家所在地
elseif Button == 2
MHCustomTeleMarkerREF03.moveto Player \ 将MHCustomTeleMarkerREF03移动到玩家所在地
endif
showmessage MHTeleportDeviceMenu01 \ 显示MHTeleportDeviceMenu01 这条message
Set MenuLevel to 2 \ 设置2级菜单
(同样,从下一级子菜单返回上一级主菜单)
endif
If TeleportSTART == 1 \ 如果TeleportSTART = 1,传送开始阶段开始
Player.PlaceAtMe EHTeleportEffects \ 在玩家身上汇聚EHTeleportEffects这个效果
DisablePlayerControls 1 1 1 1 0 1 1 \ 禁止玩家控制
imod EHFadetoWhite \ 视觉效果 EHFadetoWhite
Playsound MHTeleportSound \ 播放声音 MHTeleportSound
MHTeleportFieldMarkerREF.MoveTo Player \ 将MHTeleportFieldMarkerREF移动到玩家所在地
(这条指令就是 确定野外地点,使得玩家之后可以直接传送到本次传送前的位置)
Set TeleportSTART to 0 \ 关闭TeleportSTART
Set TeleportEND to 1 \ 开启TeleportEND
Set Timer to 3 \ 设置浮动时间值 3秒
Return
endif
If TeleportEND == 1 \ 如果TeleportEND= 1,传送结束阶段开始
Imod Addiction01ISFX \ 视觉效果 Addiction01ISFX
EnablePlayerControls \ 允许玩家控制
Player.Moveto TeleportLocation \ 把玩家移动到TeleportLocation这个地方
Set TeleportEND to 0 \ 关闭TeleportEND
Return
endif
endif
End
==============
菜单内容介绍
==============
MHTeleportDeviceMenu01的内容
MHTeleportCustomLocations 的内容
MHTeleportCustomLocationsSetup的内容
===============
与地下掩体的传送装置不同处
===============
1)地下掩体要想传送到自定义地点,只能从 终端 传送;这个script还可以通过 装置 传送
2)地下掩体的自定义地点必须是室外;这个script可以令自定义地点设在室内
===============
总结:
此文进一步讲解了show message和getbuttonpressed两条语句之间的关系。
大家以后设计时需要记得“返回上一级菜单设计”。
远程传送系统就此讲解完毕。
本帖最后由 真永恒之心 于 2011-6-10 14:24 编辑
回复 1# loveltzzm
还想问问,浮动时间如何应用?
比如我想让某个效果延迟N秒启动,如何设置? 回复 2# 真永恒之心
一般timer的应用都和 if 函数,以及一个GetSecondsPassed函数联系起来
举个小例子,比如说你想让某个效果延迟5秒:
float timer
(其他相关设置省略)
if timer < 5
set timer to timer + GetSecondsPassed
else
加入你想要的效果; 就是说5秒钟过后,你想发生什么什么
set timer to 0
endif 技术贴!
陷入MO7不能自拔{:3_152:} {:3_155:}这年头教程类的木有人看
页:
[1]