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

Project1

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

[已经解决] 请问如何读取远程的txt文件?

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2005-11-17
帖子
18
跳转到指定楼层
1
发表于 2009-7-30 23:53:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2009-7-7
帖子
480

末日的逐梦者

2
发表于 2009-7-31 10:07:14 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2005-11-17
帖子
18
3
 楼主| 发表于 2009-7-31 11:49:12 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
128 小时
注册时间
2009-1-28
帖子
2790
4
发表于 2009-7-31 12:07:52 | 只看该作者
本帖最后由 霜冻之狼 于 2009-7-31 12:09 编辑

http://rpg.blue/web/htm/news523.htm

另外可以参考这个
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
# 其中用到FantasyDR的高精度计时器,和BB转载的转UTF-8的脚本,柳柳在此表示感谢~
#==============================================================================

#=================================================================
# MTV 脚本,by 66RPG_柳柳
#=================================================================
module MTV  
#===============================================================
# 读取文件。文件相对地址:Audio/BGM
# file_name:文件名;length:MTV长度,按照.1秒为单位记数
#===============================================================
def self.load(file_name,length = 0)
   $mtv_time = []
   $mtv_text = []
   $game_system.mtv_length = length
   #=============================================================
   # 打开文件并且读取之
   #=============================================================
   file =  File.open("Audio/"+file_name)
   #=============================================================
   # 读取歌词
   #=============================================================
   for line in file.readlines
     #===========================================================
     # 转为UTF-8编码
     #===========================================================
     line = EasyConv.s2u(line)
     #===========================================================
     # 寻找本行歌词
     #===========================================================
     this_line_text = line[line.scan(/\]/).size*10,line.size]
     #===========================================================
     # 把读取的行分存成时间与文字
     #===========================================================
     for i in 0...line.scan(/\]/).size
       temp_b = line[i*10+1,8]
       temp_c = temp_b.split(/:/)[0]
       mmsecond = 600 * temp_c.to_i
       temp_c = temp_b.split(/:/)[1]
       mmsecond += 10 * temp_c.to_f
       $mtv_time.push(mmsecond.to_i)
       $mtv_text.push(this_line_text)
     end
   end
   file.close
end
#===============================================================
# 开始MTV字幕
#===============================================================
def self.mtv_begin
   $game_system.mtv_now = true
   $game_system.mtv_begin_time = $sys_timer.now()
   $lrc_text = ""
   return
end
#===============================================================
# 结束MTV字幕
#===============================================================
def self.stop
   $game_system.mtv_now = false
   return
end
#===============================================================
# 测试MTV是否播放
#===============================================================
def self.mtv?
   return $game_system.mtv_now
end
#===============================================================
# 获取MTV字幕
#===============================================================
def self.new_text
   if $game_system.mtv_now
     #===========================================================
     # 求出已经经过的时间
     #===========================================================
     nt = $sys_timer.now()
     nt -= $game_system.mtv_begin_time
     nt = nt.to_i
     nt /= 100      
     #===========================================================
     # 制作循环
     #===========================================================
     if $game_system.mtv_length>0 and nt > $game_system.mtv_length
       nt -= $game_system.mtv_length
     end
     #===========================================================
     # 放出字幕
     #===========================================================
     for tm in 0...$mtv_time.size
       if $mtv_time[tm] == nt
         $lrc_text = $mtv_text[tm]
         break
       end
     end
   else
     $lrc_text = ""
   end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ------------------------------------------------------------------------
# 高精度计时器 by FantasyDR
# ------------------------------------------------------------------------
# E-mail: [email protected]
# ------------------------------------------------------------------------
# 2005.10.18
# ------------------------------------------------------------------------
# 该类已经被定义为全局变量 $sys_timer
# 如果只需要精确到毫秒,请设置初始化参数为true
# decimal属性设置返回时间值的小数位数。
# ------------------------------------------------------------------------
# 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
# 例如 $sys_timer.clear()
# ------------------------------------------------------------------------
# clear() :计时器清零
# now() :获取当前经过的时间,单位毫秒
# now_s() :获取当前经过的时间,单位秒
# ------------------------------------------------------------------------
class SystemTimer
attr_accessor:decimal #小数位数设定,默认为3

def initialize(use_GetTime=false)
# 初始化,根据系统选择不同精度计时器
@qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
@qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
@tGetTime = Win32API.new("winmm","timeGetTime",'','L')

@decimal=3
@perf_cnt=" " * 8
@time_start=" " * 8
@time_now=" " * 8

result = @qpFrequency.call(@perf_cnt)

if use_GetTime
result = 0
end

if result!=0
@perf_flag=true
else
@perf_flag=false
@perf_cnt=[1000,0].pack('LL')
end

#设置时间比例因数
@time_scale=@perf_cnt.unpack('LL')
@time_scale[0] /= 1000.0
@time_scale[1] /= 1000.0

#起始时间清零
self.clear()
end

#-=====================-#
# 计时器清零
#-=====================-#
def clear()
if @perf_flag
@qpCounter.call(@time_start)
else
@time_start=[@tGetTime.call(),0].pack('LL')
end
end

#-==============================-#
# 获取当前经过的时间,单位毫秒
#-==============================-#
def now()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= self.scale()
return self.debug(now_time)
end

#-==============================-#
# 获取当前经过的时间,单位秒
#-==============================-#
def now_s()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= (self.scale()*1000)
return self.debug(now_time)
end

#-==============================-#
# 帧错...
#-==============================-#
def debug(now_time)
if @decimal>0
now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
else
now_time = now_time.floor
end
return now_time

#以下用于debug模式
if now_time < 0
p "Timer Wrong!! Clear...",now_time,\
@perf_flag,@qpCounter,@tGetTime,
@time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
@time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
self.clear()
return 0.0
else
return now_time
end
end

#-=====================-#
# 获取时间比例因数
#-=====================-#
def scale()
return @time_scale[0]+\
@time_scale[1]*0xffffffff
end

#-=====================-#
# 获取起始滴答数
#-=====================-#
def start()
return @time_start.unpack('LL')[0]+\
@time_start.unpack('LL')[1]*0xffffffff
end

#-=====================-#
# 获取当前的嘀哒数
#-=====================-#
def timer()
if @perf_flag
@qpCounter.call(@time_now)
else
@time_now=[@tGetTime.call(),0].pack('LL')
end
return @time_now.unpack('LL')[0]+\
@time_now.unpack('LL')[1]*0xffffffff
end
end
#-------------------------------------#
# 初始化自身成一个全局变量
#-------------------------------------#
$sys_timer=SystemTimer.new()
#-------------------------------------#




#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================


#==============================================================================
# 仭 EasyConv module - Ver 0.90
#------------------------------------------------------------------------------
# Moonlight INN
# http://cgi.members.interq.or.jp/aquarius/rasetsu/
# RaTTiE
# [email protected]
#------------------------------------------------------------
# EasyConv::s2u(text) : S-JIS -> UTF-8
# EasyConv::u2s(text) : UTF-8 -> S-JIS
#==============================================================================
module EasyConv
# API梡掕悢掕媊
  CP_ACP = 0
  CP_UTF8 = 65001

#--------------------------------------------------------------------------
# 仠 S-JIS -> UTF-8
#--------------------------------------------------------------------------
def s2u(text)
# API掕媊
  m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

# S-JIS -> Unicode
  len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  buf = "\0" * (len*2)
  m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);

# Unicode -> UTF-8
  len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  ret = "\0" * len
  w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  
  return ret
end
# module_function偲偟偰岞奐
module_function :s2u
#--------------------------------------------------------------------------
# 仠 UTF-8 -> S-JIS
#--------------------------------------------------------------------------
def u2s(text)
# API掕媊
  m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

# UTF-8 -> Unicode
  len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  buf = "\0" * (len*2)
  m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);

# Unicode -> S-JIS
  len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  ret = "\0" * len
  w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
  
  return ret
end
# module_function偲偟偰岞奐
module_function :u2s
end


#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
#  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
# $game_system 。
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :mtv_begin_time
attr_accessor :mtv_now
attr_accessor :mtv_length
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias mtv_gamesystem_initialize initialize
def initialize
   mtv_gamesystem_initialize
   @mtv_begin_time = $sys_timer.now()
   @mtv_now = false
   @mtv_length = 0
end
end  

#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  处理地图画面的类。
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias mtv_scenemap_update update
def update
   @mtv_window.refresh
   mtv_scenemap_update
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias mtv_scenemap_main main
def main
   @mtv_window = Window_MTV.new
   mtv_scenemap_main
   @mtv_window.dispose
end
#--------------------------------------------------------------------------
# ● 调用战斗 (调整自动切换BGM)
#--------------------------------------------------------------------------
def call_battle
   # 清除战斗调用标志
   $game_temp.battle_calling = false
   # 清除菜单调用标志
   $game_temp.menu_calling = false
   $game_temp.menu_beep = false
   # 生成遇敌计数
   $game_player.make_encounter_count
   # 记忆地图 BGM 、停止 BGM
   $game_temp.map_bgm = $game_system.playing_bgm
   unless MTV.mtv?      
     $game_system.bgm_play($game_system.battle_bgm)
     # 演奏战斗开始 SE
     $game_system.se_play($data_system.battle_start_se)
   end
   # 矫正主角姿势
   $game_player.straighten
   # 切换到战斗画面
   $scene = Scene_Battle.new
end
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  处理战斗的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias mtv_scenebattle_update update
def update
   @mtv_window.refresh
   mtv_scenebattle_update
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias mtv_scenebattle_main main
def main
   @mtv_window = Window_MTV.new
   mtv_scenebattle_main
   @mtv_window.dispose
end
end

#==============================================================================
# ■ Window_MTV
#------------------------------------------------------------------------------
#  显示MTV字幕的窗口。
#==============================================================================

class Window_MTV < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
   super(0, 416, 640, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   $lrc_text = ""
   self.z = 9999
   refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(text = "")
   MTV.new_text
   self.contents.clear   
   if $game_temp.in_battle
     self.opacity = 120
   else
     self.opacity = 0
   end
   self.contents.font.color = Color.new(0,0,0,255)
   self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)   
   self.contents.font.color = Color.new(255,255,255,255)
   self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)   
end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

炼金术的根本法则是等价交换。想要获得,必须失去同等价值的东西。每当烦躁的时候,煎熬在不想做却又正在做的烦心事中的时候,我就安慰自己,提醒自己做这些事情的目的所在,告诉自己不要忽略所获得或者即将获得的回报,物质的,精神的,肉体的,灵魂的回报!只做想做的事情,就会失去不想失去的东西。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2005-11-17
帖子
18
5
 楼主| 发表于 2009-7-31 12:16:39 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
20 小时
注册时间
2005-10-24
帖子
1571
6
发表于 2009-7-31 15:35:53 | 只看该作者
本地...
f = File.open("aaa.txt")
s = f.read
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
20 小时
注册时间
2005-10-24
帖子
1571
7
发表于 2009-7-31 16:08:07 | 只看该作者
不清楚rgss是否可以。但可以通过api连接vb来实现
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
8
发表于 2009-8-1 09:48:49 | 只看该作者
可以用批处理(batch)文件的FTP命令,详细参考下面这个链接:
http://www.robvanderwoude.com/ftp.php
然后在脚本中调用这个批处理文件:
system('路径/批处理文件.bat')


至于Ruby内建的方法,虽然标准库有个Net::FTP,但是RGSS引用网络库不能,所以貌似很麻烦,手头上暂时也没有相关范例,不好说
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 03:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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