设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3027|回复: 4
打印 上一主题 下一主题

[已经解决] 请问如何设置变量=自己设置的时间

[复制链接]

Lv1.梦旅人

梦石
0
星屑
75
在线时间
74 小时
注册时间
2010-5-14
帖子
27
跳转到指定楼层
1
发表于 2012-5-25 16:03:44 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 tankonsai 于 2012-5-25 16:15 编辑

以下是论坛某高手提供的时间系统
就是通过以上的代码实现了日夜交替,但要在某个时间段里道路上的行人消失或某个时间段里路灯全开。所以必须设置一个变量来控制,而问题是如何把变量=时间?



USE_CLOCK       = true
CLOCK_POSITION  = 4
CLOCK_TOGGLE = :SHIFT

module GameTime
  #---Game Time Details---#
  #Number of frames in a game minute, 60 frames = 1 second
  TIME_COUNT   = 6
  #Sets whether to tint screen based on game time
  USE_TINT = true

  #True to pause time while not in map or while during a message
  PAUSE_IN_COMBAT  = false
  PAUSE_NOT_IN_MAP = true
  PAUSE_IN_MESSAGE = true

  #Sets time frames of tints by minute count, one day is 1440 minutes
  # 0 = 12am, 360 = 6am, 720 = 12pm, 1080 = 6pm  etc...
  PRESUNRISE_TIME = 240
  SUNRISE_TIME = 360
  NOONSTART_TIME  = 660
  NOONEND_TIME = 900
  PRESUNSET_TIME  = 1080
  SUNSET_TIME  = 1260
  MIDNIGHT_TIME   = 60  #Must be greater than 0

  #Sets custome tints
  PRESUNRISE_TONE = Tone.new(-75,-75,0,50)
  SUNRISE_TONE = Tone.new(0,0,0,0)
  NOONSTART_TONE  = Tone.new(45,45,0,-25)
  NOONEND_TONE = Tone.new(0,0,0,0)
  PRESUNSET_TONE  = Tone.new(-50,-50,0,25)
  SUNSET_TONE  = Tone.new(-75,-100,0,75)
  MIDNIGHT_TONE   = Tone.new(-125,-125,0,125)

  #Include the ids of any maps not to be tinted based on time
  # Usually reserved for indoor maps
  NOTINTMAPS = [2]
  #---END---#

  def self.init
$game_time = 0
$game_time_pause_time = false
$game_time_pause_tint = false
  end
  def self.update
if $game_time_pause_time then return else end
case SceneManager::scene_is?(Scene_Map)
when true
if $game_message.visible == true && PAUSE_IN_MESSAGE then else
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
when false
if SceneManager::scene_is?(Scene_Battle) && PAUSE_IN_COMBAT != true
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
end
if $game_time == 1440 then $game_time = 0 end
GameTime::tint if $game_time_pause_tint != true
  end
  def self.hour?
return $game_time / 60
  end
  def self.minute?
return $game_time % 60
  end
  def self.time?
meri = "AM"
hour = GameTime::hour?
minute = GameTime::minute?
if hour > 11 then meri = "PM" end
if hour == 0 then hour = 12; meri = "AM" end
if hour > 12 then hour -= 12 end
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
return hour.to_s + ":" + minute.to_s + " " + meri
  end
  def self.set(number)
$game_time = number if number < 1440
GameTime::tint(0)
  end
  def self.change(number)
$game_time += number
$game_time -= 1440 if $game_time > 1440
$game_time += 1440 if $game_time < 0
GameTime::tint(0)
  end
  def self.tint(tint = 60)
if USE_TINT != true then return end
for i in NOTINTMAPS
if $game_map.map_id == i
$game_map.screen.start_tone_change(Tone.new(0,0,0,0),0)
return
end
end
if SceneManager::scene_is?(Scene_Map) then else return end
case $game_time
when PRESUNRISE_TIME .. SUNRISE_TIME
$game_map.screen.start_tone_change(PRESUNRISE_TONE, tint)
when SUNRISE_TIME .. NOONSTART_TIME
$game_map.screen.start_tone_change(SUNRISE_TONE, tint)
when NOONSTART_TIME .. NOONEND_TIME
$game_map.screen.start_tone_change(NOONSTART_TONE, tint)
when NOONEND_TIME .. PRESUNSET_TIME
$game_map.screen.start_tone_change(NOONEND_TONE, tint)
when PRESUNSET_TIME .. SUNSET_TIME
$game_map.screen.start_tone_change(PRESUNSET_TONE, tint)
when SUNSET_TIME .. 1440
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when 0 .. MIDNIGHT_TIME
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when MIDNIGHT_TIME .. PRESUNRISE_TIME
$game_map.screen.start_tone_change(MIDNIGHT_TONE, tint)
end
  end
  def self.pause_time(set)
$game_time_pause_time = set
  end
  def self.pause_tint(set)
$game_time_pause_tint = set
  end
  def self.clock(set)
SceneManager.scene.clock_visible?(set)
  end

  class Window_Clock < Window_Base
def initialize
case CLOCK_POSITION
when 1
super(0,0,115,56)
when 2
super(429,0,115,56)
when 3
super(0,360,115,56)
when 4
super(429,360,115,56)
end
end
def update
self.contents.clear
self.contents.draw_text(0,0,100,24,GameTime::time?)
end
  end

end

module DataManager
  class << self
  alias gametime_msc make_save_contents
  alias gametime_esc extract_save_contents
  end
  def self.make_save_contents
contents = gametime_msc
contents[:gametime] = $game_time
contents
  end
  def self.extract_save_contents(contents)
gametime_esc(contents)
$game_time = contents[:gametime]
  end
end


class Scene_Map < Scene_Base
  alias gametime_post_transfer post_transfer
  alias gametime_create_all_windows create_all_windows
  alias gametime_update_map update
  def post_transfer
GameTime::tint(0)
gametime_post_transfer
  end
  def create_all_windows
gametime_create_all_windows
@gametimeclock = GameTime::Window_Clock.new if USE_CLOCK
  end
  def update
gametime_update_map
@gametimeclock.update if @gametimeclock.nil? == false
if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false
@gametimeclock.visible ? @gametimeclock.visible = false : @gametimeclock.visible = true
end
  end
  def clock_visible?(set)
@gametimeclock.visible = set
  end
end

class Scene_Base
  alias gametime_update update
  def update
gametime_update
GameTime::update
  end
end

GameTime::init

Lv1.梦旅人

梦石
0
星屑
50
在线时间
629 小时
注册时间
2009-9-24
帖子
570
2
发表于 2012-5-25 16:49:17 | 只看该作者
不懂脚本…但我做过事件版…你需要么?
十三工坊式作型人形兵器驾驶员
“和基巴君是不同的!和基巴君!”
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
5 小时
注册时间
2012-5-24
帖子
14
3
发表于 2012-5-25 17:12:03 | 只看该作者
本帖最后由 键山雏 于 2012-5-25 17:23 编辑

若要获得时间前进的帧数,则事件→脚本中写入
  1. $game_variables[n] = $game_time
复制代码
--------
若要获得现在的小时则事件→脚本写入
  1. hour = GameTime::hour?
  2. if hour == 0 then hour = 12 end
  3. if hour > 12 then hour -= 12 end
  4. if hour < 10 then hour = " " + hour.to_s
  5. else hour.to_s end
  6. $game_variables[n] = hour.to_i
复制代码
--------
若要获得现在的小时则事件→脚本写入
  1. minute = GameTime::minute?
  2. if minute < 10 then minute = "0" +
  3. minute.to_s else minute.to_s end
  4. $game_variables[1] = minute.to_i
复制代码
--------
若要获得现在AM还是PM则事件→脚本写入
  1. meri = "AM"
  2. hour = GameTime::hour?
  3. if hour > 11 then meri = "PM" end
  4. if hour == 0 then hour = 12; meri = "AM" end
  5. $game_variables[1] = meri
复制代码
(注:以上内容里的n为你需要储存时间的变量id)

评分

参与人数 1星屑 +200 梦石 +2 收起 理由
迷糊的安安 + 200 + 2 认可答案 附赠66RPG提供的精美好人卡一张^^.

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
75
在线时间
74 小时
注册时间
2010-5-14
帖子
27
4
 楼主| 发表于 2012-5-25 17:34:22 | 只看该作者
首先感谢2楼,谢谢你的热心帮忙。
感谢3楼的网友,但是出现了一个错误



‘‘──tankonsai于2012-5-25 17:43补充以下内容

哦,可以了,谢谢3楼网友的帮助!
’’

未命名.jpg (11.95 KB, 下载次数: 24)

未命名.jpg
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
681
在线时间
791 小时
注册时间
2011-10-20
帖子
2394

开拓者

5
发表于 2012-5-27 13:37:37 | 只看该作者
很麻烦...
还不如进入游戏的时候来个:$time = Time.now
然后查询的时候 显示:Time.now - $time
就行了,时间交给SYSTEM。
存档的时候就吧这个存进去,下次读取加回来呗.......
欢迎点此进入我的egames.wink.ws,有RMQQ堂等

[url=http://rpg.blue/thread-317273-1-1.html]短篇八-赶选

http://yun.baidu.com/share/link?shareid=2158225779&uk=169642147&third=0


历险ARPG赢回你的疆域新的战斗模式?…………点击这里:[宋乱贼狂 for QQ堂]
http://rpg.blue/group-368-1.html
programing ....?
[url=http://rpg.blue/thrd-234658-1-1.html]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-14 09:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表