0

我不知道出了什么问题,因为它不是实际的代码……我有一组男孩的标签,我把每一组(爱的兴趣)标签拿出来单独运行)……他们工作得很好。但是,当我关闭它并尝试重新打开所有集合时,它反而会打开一个回溯错误,而前两行则出现上述错误。

“加载脚本后。OverflowError: value too large to convert to short.

有代码长度限制还是什么?我的项目是一个约会模拟游戏,有 12 个可能的爱情兴趣……今天,当我完成了将近 50% 时,它开始搞砸了……

我不认为我应该

有没有办法让 Ren'py 的代码“太长”?

编辑:这是完整的追溯:

Full traceback:
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\bootstrap.py", line 265, in bootstrap
    renpy.main.main()
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\main.py", line 263, in main
    if renpy.parser.report_parse_errors():
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\parser.py", line 2093, in report_parse_errors
    renpy.display.error.report_parse_errors(full_text, error_fn)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\error.py", line 157, in report_parse_errors
    error_fn = error_fn,
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\game.py", line 323, in invoke_in_new_context
    return callable(*args, **kwargs)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\error.py", line 42, in call_exception_screen
    return renpy.ui.interact(mouse="screen", type="screen", suppress_overlay=True, suppress_underlay=True)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 2165, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\core.py", line 1420, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 365, in renpy.display.render.render_screen (gen\renpy.display.render.c:4568)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 521, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 521, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 521, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\screen.py", line 295, in render
    child = renpy.display.render.render(self.child, w, h, st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 521, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "accelerator.pyx", line 109, in renpy.display.accelerator.transform_render (gen\renpy.display.accelerator.c:1298)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 889, in render
    st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 1552, in render
    cwidth, cheight = sizeit('c', width, height, 0, 0)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 1547, in sizeit
    rend = render(pos_d[pos], width, height, st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 1311, in render
    surf = render(self.child, child_width, child_height, st, at)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\display\layout.py", line 683, in render
    surf = render(d, width - x, rh, cst, cat)
  File "render.pyx", line 95, in renpy.display.render.render (gen\renpy.display.render.c:2291)
  File "render.pyx", line 166, in renpy.display.render.render (gen\renpy.display.render.c:2033)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\text\text.py", line 1363, in render
    layout = Layout(self, width, height, renders)
  File "C:\Users\Jessinia\Downloads\renpy-6.15.7-sdk\renpy\text\text.py", line 593, in __init__
    textsupport.align_and_justify(lines, maxx, style.text_align, style.justify)
  File "textsupport.pyx", line 728, in renpy.text.textsupport.align_and_justify (gen\renpy.text.textsupport.c:7288)
OverflowError: value too large to convert to short

Windows-post2008Server-6.2.9200
Ren'Py 6.15.7.374
4

2 回答 2

3

我下载了 Ren'Py SDK 来看看发生了什么。

这是引发错误的函数,在renpy/text/textsupport.pyx

def align_and_justify(list lines, short width, float text_align, bint justify):

您可以看到唯一short的是宽度,即您在屏幕上放置的文本的宽度。不知何故,一个大于 32,767 的数字作为宽度传入。查看中的调用代码,renpy/text/text.py我可以看到宽度可以来自段落的最大宽度,也可以来自样式的最小宽度。我希望这能给你一个关于在哪里看的线索。


然后是您发表的评论:

有代码长度限制还是什么?我的项目是一个约会模拟游戏,有 12 个可能的爱情兴趣……今天,当我完成了将近 50% 时,它开始搞砸了……

听起来您没有使用版本控制。

使用版本控制!

立即下载 Git(或 Mercurial、SVN、Bazaar、Darcs、Perforce、CVS 等),并将您项目纳入修订控制。当您正确使用修订控制时,没有“搞砸”之类的事情,只有“浪费时间”,因为如果你搞砸了,你总是可以回到项目的旧版本,你甚至可以找出哪个改变搞砸了。


Ren'py添加调试

我会尝试renpy/text/text.py在包含align_and_justify(). 这是我添加的代码,以及一些周围的 Ren'py 代码:

sw, sh = size = (maxx + self.xborder, y + self.yborder)
self.size = size

# Add these two lines
# Indentation is important, and use spaces not tabs to indent
if not (-32768 <= maxx <= 32767):
    raise ValueError('failed on text: %r' % ' '.join(s for ts, s in p))

textsupport.align_and_justify(lines, maxx, style.text_align, style.justify)

这至少会告诉您脚本中的哪个段落触发了错误。

于 2013-08-27T04:43:27.250 回答
1

Python基本上是在说你有一个太大而无法转换为短的数字

在python中,当一个数字非常大时,它会变成这样的长,它用一个表示L

>>> import math
>>> math.factorial(1000)
40238726...L

你的代码对 Ren'py 来说并不长,但你的代码有一个价值,那就是大到变短

在此处了解有关长整数对象的更多信息

于 2013-08-27T03:38:18.153 回答