当前位置: 首页 > news >正文

如何设计和建立一个公司的网站网站推广软文范例

如何设计和建立一个公司的网站,网站推广软文范例,长沙seo培训班,wordpress 2万条就卡饥荒Mod 开发(二一):超大便携背包,超大物品栏,永久保鲜 饥荒Mod 开发(二三):显示物品栏详细信息 饥荒中的物品没有详细信息,基本上只有一个名字,所以很多物品的功能都不知道,比如浆果吃了也不知…

饥荒Mod 开发(二一):超大便携背包,超大物品栏,永久保鲜
饥荒Mod 开发(二三):显示物品栏详细信息

饥荒中的物品没有详细信息,基本上只有一个名字,所以很多物品的功能都不知道,比如浆果吃了也不知道恢复什么, 采集的胡萝卜也不知
道什么功效,可真是太不方便了,所以当我们把鼠标放在物品上面时需要显示物品的详细信息。

原理

widgets/hoverer 类用来显示鼠标悬浮的提示,所以我们需要拦截这个 悬浮的创建,设置需要显示的内容

显示自定义提示

在modmain.lua 文件中添加下面代码用来拦截 widgets/hoverer 创建,然后重写 SetString 方法


local round2 =function(num, idp)return GLOBAL.tonumber(string.format("%." .. (idp or 0) .. "f", num))
end
--鼠标悬浮在物品上显示信息
AddClassPostConstruct("widgets/hoverer",function(self)local old_SetString = self.text.SetStringself.text.SetString = function(text,str)-- 获取鼠标下的世界实体local target = GLOBAL.TheInput:GetWorldEntityUnderMouse() -- 如果存在目标实体if target   then-- 如果目标实体有预制体if target.prefab then-- 在字符串后添加预制体的代码str = str .. "\n代码: " .. target.prefabend-- 如果目标实体有可旅行组件if target.components.travelable then-- 在字符串后添加可旅行组件的名称str = str .."\n".. tostring(target.components.travelable.name)endif target.components then-- 如果目标实体有生命组件if target.components.health then-- 在字符串后添加生物的血量str = str.."\n"..math.ceil(target.components.health.currenthealth*10)/10 .."/"..math.ceil(target.components.health.maxhealth*10)/10end-- 如果目标实体有战斗组件,并且默认伤害大于0if target.components.combat and target.components.combat.defaultdamage > 0 then-- 在字符串后添加生物的攻击力str = str.."\n攻击力: "..target.components.combat.defaultdamageend-- 如果目标实体是温度计if target.prefab == "winterometer" then-- 获取当前温度local temp = GLOBAL.GetSeasonManager() and GLOBAL.GetSeasonManager():GetCurrentTemperature() or 30local high_temp = TUNING.OVERHEAT_TEMPlocal low_temp = 0-- 限制温度在最高温度和最低温度之间temp = math.min( math.max(low_temp, temp), high_temp)-- 在字符串后添加温度str = str.."\n温度: ".. tostring(math.floor(temp)) .. "\176C"end-- 检查目标实体是否有库存组件if target.components.inventory then-- 获取目标实体手部装备的物品local handitem = target.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HANDS)if handitem then-- 如果有手部装备的物品,可以在这里添加相关的处理代码end-- 获取目标实体头部装备的物品local headitem = target.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.HEAD)if headitem then-- 如果头部装备的物品有防具组件if headitem.components.armor then-- 在字符串后添加头部防御的信息str = str.."\n头部防御: "..headitem.components.armor.absorb_percent*100 .."%"-- 在字符串后添加头部装备的耐久信息str = str.." 耐久: "..math.floor(headitem.components.armor:GetPercent() *100).."%"endend-- 获取目标实体身体装备的物品local bodyitem = target.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.BODY)if bodyitem then-- 如果身体装备的物品有防具组件if bodyitem.components.armor then-- 在字符串后添加身体防御的信息str = str.."\n身体防御: "..bodyitem.components.armor.absorb_percent*100 .."%"-- 在字符串后添加身体装备的耐久信息str = str.." 耐久: "..math.floor(bodyitem.components.armor:GetPercent() *100).."%"endendend-- 检查目标实体是否可以被驯养if target.components.domesticatable ~= nil then-- 如果目标实体有驯养和顺从的方法if target.components.domesticatable.GetDomestication and target.components.domesticatable.GetObedience ~= nil then-- 获取目标实体的饥饿值local hunger = target.components.hunger.current-- 获取目标实体的顺从值local obedience = target.components.domesticatable:GetObedience()-- 获取目标实体的驯养值local domestication = target.components.domesticatable:GetDomestication()-- 如果驯养值不为0if domestication ~= 0 then-- 在字符串后添加饥饿、顺从和驯养的信息str = str.."\n饥饿: "..round2(hunger).."\n顺从: "..round2(obedience*100,0).."%".."\n驯服: "..round2(domestication*100,0).."%"end-- 遍历目标实体的倾向for k,v in pairs(target.components.domesticatable.tendencies) do-- 默认倾向为"默认"local ten = "默认"-- 如果倾向为ORNERY,则设置为"战牛"if k == GLOBAL.TENDENCY.ORNERY thenten = "战牛"-- 如果倾向为RIDER,则设置为"行牛"elseif k == GLOBAL.TENDENCY.RIDER thenten = "行牛"-- 如果倾向为PUDGY,则设置为"肥牛"elseif k == GLOBAL.TENDENCY.PUDGY thenten = "肥牛"end-- 在字符串后添加倾向的信息str = str .. string.format("\n %s:%.2f", ten, v)endendend-- 检查目标实体是否可以被采摘,并且有目标时间if target.components.pickable and target.components.pickable.targettime then-- 在字符串后添加距离成长的时间(树枝、草、浆果、咖啡树)str = str .."\n距离成长: " .. tostring(math.ceil((target.components.pickable.targettime - GLOBAL.GetTime())/48)/10) .." 天"end-- 检查目标实体是否可以被砍伐,并且有目标时间if target.components.hackable and target.components.hackable.targettime then-- 在字符串后添加距离成长的时间(藤蔓、竹林)str = str.."\n距离成长: "..tostring(math.ceil((target.components.hackable.targettime - GLOBAL.GetTime())/48)/10).." 天"end-- 检查目标实体是否可以被部署,并且有生长时间if target.components.deployable and target.growtime then-- 在字符串后添加树苗的生长时间str = str.."\n树苗: "..tostring(math.ceil((target.growtime - GLOBAL.GetTime())/48)/10).." 天"end-- 检查目标实体是否可以成长,并且有目标时间if target.components.growable and target.components.growable.targettime then-- 在字符串后添加下一阶段的时间(树)str = str.."\n下一阶段: "..tostring( math.ceil((target.components.growable.targettime - GLOBAL.GetTime())/48)/10).." 天"end-- 检查目标实体是否有晾肉架组件,并且正在晾肉if target.components.dryer and target.components.dryer:IsDrying() then-- 如果正在晾肉,并且有获取晾肉时间的方法if target.components.dryer:IsDrying() and target.components.dryer.GetTimeToDry then-- 在字符串后添加剩余的晾肉时间str = str.."\n剩余: "..round2((target.components.dryer:GetTimeToDry()/TUNING.TOTAL_DAY_TIME)+0.1,1).." 天"endend-- 检查目标实体是否有烹饪组件,并且烹饪时间大于0if target.components.stewer and target.components.stewer:GetTimeToCook() > 0 then-- 计算剩余的烹饪时间local tm = math.ceil(target.components.stewer.targettime-GLOBAL.GetTime(),0)-- 获取烹饪的食物名称local cookname = GLOBAL.STRINGS.NAMES[string.upper(target.components.stewer.product)]-- 如果剩余时间小于0,则设置为0if tm <0 then tm=0 end-- 在字符串后添加正在烹饪的食物和剩余时间str = str .."\n正在烹饪: "..tostring(cookname).."\n剩余时间(秒): "..tmend-- 检查目标实体是否有农作物组件,并且有生长百分比if target.components.crop and target.components.crop.growthpercent then-- 如果有产品预制体if target.components.crop.product_prefab then-- 在字符串后添加产品的名称str = str.."\n"..(GLOBAL.STRINGS.NAMES[string.upper(target.components.crop.product_prefab)])end -- 如果生长百分比小于1if target.components.crop.growthpercent < 1 then-- 在字符串后添加距离成长的百分比str = str.."\n距离成长: "..math.ceil(target.components.crop.growthpercent*1000)/10 .."%" end    end-- 检查目标实体是否有燃料组件,并且不是库存目标if target.components.fueled and not target.components.inventorytarget then-- 在字符串后添加燃料的百分比str = str.."\n燃料: "..math.ceil((target.components.fueled.currentfuel/target.components.fueled.maxfuel)*100) .."%" end-- 检查目标实体是否有追随者组件,并且有最大追随时间if target.components.follower and target.components.follower.maxfollowtime then-- 获取最大追随时间mx = target.components.follower.maxfollowtime-- 计算当前的忠诚百分比cur = math.floor(target.components.follower:GetLoyaltyPercent()*mx+0.5)-- 如果当前的忠诚百分比大于0if cur>0 then-- 在字符串后添加忠诚的百分比str = str.."\n忠诚: "..curendend-- 检查目标实体是否有船耐久组件if target.components.boathealth  then-- 在字符串后添加船的当前耐久和最大耐久str = str.."\n船: "..math.ceil(target.components.boathealth.currenthealth).."/"..target.components.boathealth.maxhealthend-- 检查目标实体是否有有限使用组件if target.components.finiteuses then-- 如果有消耗属性if target.components.finiteuses.consumption thenlocal use = 1-- 遍历消耗属性for k,v in pairs(target.components.finiteuses.consumption) douse = vend-- 在字符串后添加耐久的当前值和总值str = str .."\n耐久: "..math.floor(target.components.finiteuses.current/use+.5).."/"..math.floor(target.components.finiteuses.total/use+.5)else-- 在字符串后添加耐久的当前值和总值str = str .."\n耐久: "..target.components.finiteuses.current.."/"..target.components.finiteuses.total end  end-- 检查目标实体是否有可工作组件if target.components.workable then-- 获取工作动作local action =  target.components.workable:GetWorkAction()-- 在字符串后添加工作动作str = str .."\n动作: ".. tostring(action.id)end-- 检查目标实体是否有生长组件if target.components.growth then-- 在字符串后添加等级和经验值str = str .. "\n等级:" .. target.components.growth:GetLevel() .. " (经验: "..target.components.growth:GetCurrentExp().."/"..target.components.growth:GetCurrentMaxExp() .. ")"endendendreturn old_SetString(text,str)end
end)

添加完上面代码之后就可以进入游戏测试,将鼠标放在物品上就会显示详细信息了
在这里插入图片描述`

在这里插入图片描述

http://www.bjxfkj.com.cn/article/100777.html

相关文章:

  • 做h的动漫在线观看网站我要推广
  • 南京 做网站竞价排名的服务模式是
  • 高密做网站哪家强代理谷歌搜索引擎免费入口
  • 网页托管北京seo百度推广
  • 引航博景网站做的好吗友情链接有什么用
  • 路桥做网站中国教师教育培训网
  • 上海做网站的整站优化seo
  • 学校网站 建设 价格晋城网站seo
  • 上海市奉贤区建设局网站友情链接网站源码
  • 网站 宗旨东莞软文推广
  • 深圳品牌设计公司哪家好seox
  • 中国新闻周刊优化大师是什么意思
  • 品牌网站建设怎么做原画培训机构哪里好
  • 十大网站app排行榜做网站怎么做
  • 备案需要网站建设方案书长沙seo优化排名
  • 如何建立自己的网站步骤搜索推广渠道有哪些
  • 宜昌网站建设多少钱营销策略主要包括哪些
  • 创网站多少钱常用的网络推广方法有
  • 上海做网站哪个好上海排名seo公司
  • 远程教育网站建设方案长岭网站优化公司
  • 网站开发榜单规则windows系统优化软件
  • wordpress 安全性设置武汉seo推广
  • 网站建设指导日结app推广联盟
  • 手机网站 cms百度官网入口链接
  • 37游戏平台seo模拟点击算法
  • 西湖网站建设电子商务网站建设流程
  • 查网站开通时间网站seo 优化
  • 企业网站更新频率软文免费发布平台
  • 猪价格网免费手机优化大师下载安装
  • 青岛网站开发学校引擎搜索