马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 Fridde 于 2020-4-10 19:02 编辑
我目前碰到两个问题毫无头绪,希望有大佬能解惑或者给个思路
1、奇怪的无效值
程序头定义了一个嵌套的字典用来存储数据信息,定义如下:
[RenPy] 纯文本查看 复制代码 define DroneINFO = {
"0" : {"model_name" : "当前无可用设计"},
"1" : {"model_name" : "简单原始款", "design_progress" : 0, "design_increase" : 10, "design_done" : False, "inventory" : 0, "is_unlock" : True, "selling_price" : 800, "package_progress" : 0},
"2" : {"model_name" : "飞行强化款", "design_progress" : 0, "design_increase" : 5, "design_done" : False, "inventory" : 0, "is_unlock" : False, "selling_price" : 1500, "package_progress" : 0},
"3" : {"model_name" : "拍摄强化款", "design_progress" : 0, "design_increase" : 5, "design_done" : False, "inventory" : 0, "is_unlock" : False, "selling_price" : 1500, "package_progress" : 0},
"4" : {"model_name" : "迷你便携款", "design_progress" : 0, "design_increase" : 5, "design_done" : False, "inventory" : 0, "is_unlock" : False, "selling_price" : 1100, "package_progress" : 0},
"5" : {"model_name" : "旗舰级设计", "design_progress" : 0, "design_increase" : 2, "design_done" : False, "inventory" : 0, "is_unlock" : False, "selling_price" : 2700, "package_progress" : 0},
}
其他键值部分调用都无问题。只有 ‘package_progress’这部分会莫名其妙报错:
报错部分的代码如下,making_select是一个变量,开头有定义default making_select = "0",后续根据按钮切换值:
[RenPy] 纯文本查看 复制代码 screen busniess_status():
python:
work_cur_design = DroneINFO[blueprint_select]["model_name"]
work_used_blueprint = DroneINFO[making_select][ "model_name"]
work_cur_design_complet = DroneINFO[blueprint_select]["design_progress"]
work_progress = DroneINFO[making_select]['package_progress']
vbox:
xpos 230 ypos 382
text "[work_cur_design]" color"#d0cfcb"
text "设计完成度:[work_cur_design_complet]%" style "quick_button_text" color"#d0cfcb"
null height 29
text "拥有[work_cur_material]%零件" color"#d0cfcb"
null height 27
text "[work_used_blueprint]" color"#d0cfcb"
text "组装完成度:[work_progress]%" color"#d0cfcb" style "quick_button_text"
null height 25
text "[work_cur_requires]" color"#d0cfcb"
报错提示↓
让我想不通的是前三句调用都没问题,只有第四句涉及到了package_progress这个键值就报错。
注释掉work_progress = DroneINFO[making_select]['package_progress']后就不报错,这是为什么呀?
而且在程序的其他部分也多次通过 DroneINFO[making_select]['package_progress'] 调用数据,也都不报错
2、界面刷新
我现在有一个screen busniess_status ,里面的文字按钮需要通过变量判断是否显示:
[RenPy] 纯文本查看 复制代码 screen busniess_status():
hbox:
xpos 1360 ypos 590
if DroneINFO["1"]["design_done"]:
textbutton "简单原始款" text_size 24 action SetVariable("making_select","1")
null width 30
if DroneINFO["2"]["design_done"]:
textbutton "飞行强化款" text_size 24 action SetVariable("making_select","2")
null width 30
if DroneINFO["3"]["design_done"]:
textbutton "拍摄强化款" text_size 24 action SetVariable("making_select","3")
这是调用到这个screen的label, 这里的 main_work_interface 里包含一个imagemap来触发各种功能。
[RenPy] 纯文本查看 复制代码 label Main_Mystudio:
scene bg mystudio_interface
show screen top_ui_bar
show screen busniess_status
show screen tooltip_screen
call screen main_work_interface
当我通过main_work_interface里的功能改变了 DroneINFO["1"]["design_done"] 的值后,对应按钮并没有当场出现。
只有当我跳转到Main_Mystudio意外的label后,再次跳转回来,busniess_status 里的按钮才判定满足if条件显示textbutton。补张图示方便理解↓
请问是否有啥办法可以立即显示?
|