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

Project1

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

[讨论] 最近爱上拿别人的脚本来改了(RM计算器)

[复制链接]

Lv2.观梦者

梦石
0
星屑
635
在线时间
244 小时
注册时间
2010-9-9
帖子
472
跳转到指定楼层
1
发表于 2010-12-6 12:00:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 EngShun 于 2010-12-6 12:48 编辑

最近脑残的爱上拿别人的脚本来改了,导致现在我只有两个原创作品:L
比如说,物品分类,武器打造,都是拿别人的脚本来改的T.T
一直拿别人的脚本来改总是不会有出息的
但是我还是拿别人的脚本来改,那天我拿滚动字幕来改,
改到乱七八糟,最后自己都嫌乱丢了:L
昨天无意间看到七夕小雨的RM计算器
输入1 / 0 之后出了问题,解决此问题后一时兴起就这样栽了下去
结果出了以下这个强化版(注释嫌太麻烦杀光了
  1. #==========================================================================
  2. # RM计算机……无用产物之一
  3. # 脚本作者 by 七夕小雨
  4. # 强化 by EngShun
  5. # 注释被 EngShun 杀光了 (-_-||)
  6. #============================================================================
  7. class Window_Command_Calculator < Window_Selectable
  8.   def initialize(width, commands, column=1)
  9.     row = commands.size / column
  10.     rowrem = commands.size % column
  11.     if rowrem != 0
  12.       row +=1
  13.     end
  14.     super(0, 0, width, row * 32 + 32)
  15.     @item_max = commands.size
  16.     @commands = commands
  17.     @row = row
  18.     @width_txt = (width-32)/column
  19.     @column_max = column
  20.     self.contents = Bitmap.new(width-32, @row * 32)
  21.     refresh
  22.     self.index = 0
  23.   end
  24.   def refresh
  25.     self.contents.clear
  26.     self.contents.font.size = 18
  27.     for i in 0...@item_max
  28.       draw_item(i, normal_color)
  29.     end
  30.   end
  31.   def draw_item(index, color)
  32.     self.contents.font.color = color
  33.     row_index = index / @column_max
  34.     for y in 0...@column_max
  35.       if index % @column_max == y
  36.         rect = Rect.new(y * @width_txt, 32 * row_index , @width_txt, 32)
  37.         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  38.         self.contents.draw_text(rect, @commands[index],1)
  39.         break
  40.       end
  41.     end
  42.   end
  43.   def update_cursor_rect
  44.     if @index < 0
  45.       self.cursor_rect.empty
  46.       return
  47.     end
  48.     row = @index / @column_max
  49.     if row < self.top_row
  50.       self.top_row = row
  51.     end
  52.     if row > self.top_row + (self.page_row_max - 1)
  53.       self.top_row = row - (self.page_row_max - 1)
  54.     end
  55.     cursor_width = @width_txt
  56.     x = @index % @column_max * cursor_width
  57.     y = @index / @column_max * 32 - self.oy
  58.     self.cursor_rect.set(x, y, @width_txt, 32)
  59.   end
  60. end
  61. class Window_Calculator < Window_Base
  62.   def initialize
  63.     super(250, 101, 180, 64)
  64.     self.contents = Bitmap.new(width - 32, height - 32)
  65.     @welcome_text = "RM CALCULATOR"
  66.     set_text(@welcome_text)
  67.   end
  68.   def set_text(text)
  69.     self.contents.clear
  70.     @text = text
  71.     self.contents.font.color = normal_color
  72.     if @text == "MATH ERROR"
  73.       self.contents.font.color = Color.new(255,0,0)
  74.       self.contents.draw_text(0, 0, 149, 32, @text, 1)
  75.     elsif @text == @welcome_text
  76.       self.contents.font.color = Color.new(0, 0, 255)
  77.       self.contents.draw_text(0, 0, 149, 32, @text, 1)
  78.     else
  79.       self.contents.font.color = Color.new(0,0,0)
  80.       self.contents.draw_text(0, 0, 149, 32, @text, 2)
  81.     end
  82.   end
  83. end
  84. class Scene_Calculator
  85.   def main
  86.     @back = Spriteset_Map.new
  87.     @command_window = Window_Command_Calculator.new(180, ["1","2","3","4","5","6","7","8","9","0","+","-","×","÷","x2","丌","REM","=","AC","OFF"],4)
  88.     @command_window.x = 320 - @command_window.width / 2
  89.     @command_window.y = 165
  90.     @command_window.index = 0
  91.     @compute_window = Window_Calculator.new
  92.     @compute_window.x = @command_window.x
  93.     @v = Viewport.new(240,121,160,24)
  94.     @v.z = @compute_window.z + 1
  95.     @v.color.set(250,250,250)
  96.     @c = 0
  97.     @ans = true
  98.     Graphics.transition
  99.     loop do
  100.       Graphics.update
  101.       Input.update
  102.       update
  103.       if $scene != self
  104.         break
  105.       end
  106.     end
  107.     Graphics.freeze
  108.     @v.dispose
  109.     @compute_window.dispose
  110.     @command_window.dispose
  111.     @back.dispose
  112.   end
  113.   def update
  114.     @compute_window.update
  115.     @command_window.update
  116.     if @command_window.active
  117.       update_command
  118.       return
  119.     end
  120.   end
  121.   def update_command
  122.     if Input.trigger?(Input::B)
  123.       $game_system.se_play($data_system.cancel_se)
  124.       $scene = Scene_Map.new
  125.       return
  126.     end
  127.     if Input.trigger?(Input::C)
  128.       case @command_window.index
  129.       when 0..18
  130.         $game_system.se_play($data_system.decision_se)
  131.       when 19
  132.         $game_system.se_play($data_system.cancel_se)
  133.       end
  134.       if @ans == true
  135.         @z = 0
  136.         @compute = "0"
  137.         @Operation = 0
  138.         @ans = false
  139.       end
  140.       case @command_window.index
  141.       when 0..8
  142.         if @compute != "0"
  143.           @compute += "#{@command_window.index + 1}"
  144.         else
  145.           @compute = "#{@command_window.index + 1}"
  146.         end
  147.       when 9
  148.         if @compute != "0"
  149.           @compute += "0"
  150.         end
  151.       when 10  
  152.         update_number
  153.         if @ans != true
  154.           @a = @compute.to_i
  155.           @Operation = 1
  156.           @compute = "0"
  157.         end
  158.       when 11  
  159.         update_number
  160.         if @ans != true
  161.         @a = @compute.to_i
  162.         @Operation = 2
  163.         @compute = "0"
  164.         end
  165.       when 12  
  166.         update_number
  167.         if @ans != true
  168.         @a = @compute.to_i
  169.         @Operation = 3
  170.         @compute = "0"
  171.         end
  172.       when 13  
  173.         update_number
  174.         if @ans != true
  175.           @a = @compute.to_i
  176.           @Operation = 4
  177.           @compute = "0"
  178.         end
  179.       when 14
  180.         update_number
  181.         if @ans != true
  182.         if @c != 0
  183.           @a = @c
  184.         else
  185.           @a = @compute.to_i
  186.         end
  187.         @a = @a ** 2
  188.         @compute = @a.to_s
  189.         @ans = true
  190.         end
  191.       when 15
  192.         update_number
  193.         if @ans != true
  194.         if @c != 0
  195.           @a = @c
  196.         else
  197.           @a = @compute.to_i
  198.         end
  199.         @q = @a * 22 / 7.00
  200.         @compute = @q.to_s
  201.         @ans = true
  202.         end
  203.       when 16
  204.         update_number
  205.         if @ans !=true
  206.         @a = @compute.to_i
  207.         @Operation = 5
  208.         @compute = "0"
  209.         end
  210.       when 17
  211.         update_number
  212.         if @ans != true
  213.         if @c != 0
  214.           @a = @c
  215.         end
  216.         case @Operation
  217.         when 1
  218.           @b = @compute.to_i
  219.           @d = @a + @b
  220.           @d = @d.to_s
  221.           @compute = @d
  222.         when 2
  223.           @b = @compute.to_i
  224.           @d = @a - @b
  225.           @d = @d.to_s
  226.           @compute = @d
  227.         when 3
  228.           @b = @compute.to_i
  229.           @d = @a * @b
  230.           @d = @d.to_s
  231.           @compute = @d
  232.         when 4
  233.           @b = @compute.to_i
  234.           if @b != 0
  235.             @d = @a / @b.to_f
  236.           end
  237.           @d = @d.to_s
  238.           if @b == 0
  239.             @compute = "MATH ERROR"
  240.             @ans = true
  241.           else
  242.             @compute = @d
  243.           end
  244.         when 5
  245.           @b = @compute.to_i
  246.           if @b != 0
  247.             @d = @a % @b
  248.           end
  249.           @d = @d.to_s
  250.           @d = @d.to_s
  251.           if @b == 0
  252.             @compute = "MATH ERROR"
  253.             @ans = true
  254.           else
  255.             @compute = @d
  256.           end
  257.         end
  258.         end
  259.       when 18
  260.         @compute = "0"
  261.         @Operation = 0
  262.         @c = 0
  263.         @z = 0
  264.       when 19
  265.         $scene = Scene_Map.new
  266.         return
  267.       end
  268.       @compute_window.set_text(@compute)
  269.       return
  270.     end
  271.   end
  272.   def update_number
  273.     if @Operation != 0
  274.       if @c != 0
  275.         @a = @c
  276.       end
  277.       case @Operation
  278.       when 1
  279.         @b = @compute.to_i
  280.         @c = @a + @b
  281.         @compute = "0"
  282.       when 2
  283.         @b = @compute.to_i
  284.         @c = @a - @b
  285.         @compute = "0"
  286.       when 3
  287.         @b = @compute.to_i
  288.         @c = @a * @b
  289.         @compute = "0"
  290.       when 4
  291.         @b = @compute.to_i
  292.         if @b != 0
  293.           @c = @a / @b.to_f
  294.         else
  295.           @compute = "MATH ERROR"
  296.           @ans = true
  297.         end
  298.       when 5
  299.         @b = @compute.to_i
  300.         if @b != 0
  301.           @c = @a % @b
  302.         else
  303.           @compute = "MATH ERROR"
  304.           @ans = true
  305.         end
  306.       end
  307.     end
  308.   end
  309. end
复制代码
简单说明一下
调用方法:$scene = Scene_Calculator.new
“x2”,比如说输入4“x2”会拿到16,也就是4 square 的意思
“丌”就是圆周率,输入7“丌”会拿到 22
“REM”是算余数
拿别人的脚本来改总是觉得很杯具T.T

Lv4.逐梦者

梦石
0
星屑
6545
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

2
发表于 2010-12-6 12:18:56 | 只看该作者
这样的标题可不利于“搜索”

点评

谢谢提醒  发表于 2010-12-6 12:49











你知道得太多了

回复 支持 反对

使用道具 举报

Lv1.梦旅人

小小的百鬼夜行<

梦石
0
星屑
54
在线时间
579 小时
注册时间
2010-7-29
帖子
2682

贵宾

3
发表于 2010-12-6 19:48:00 | 只看该作者
强化……
事实上我的脚本也是拿别人的修改而成的TAT
赞一个。
某只PHP/HTML小白鼠→退屈の间


Cause I knew you were trouble when you walked in
So shame is on me now
I flow me to place i ve never been
till you put me down oh
Now Im lying on the cold hard ground
回复 支持 反对

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
4
发表于 2010-12-8 13:12:29 | 只看该作者
为啥要用兀不用π- -

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 20:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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