iiYO Community

Full Version: RenPy to WebStoryEngine converter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4

Guest

Hey, I have some good news, looks like I have successfully supported 'with Dissolve(time)' and 'with Fade(time,time,time,color=color)', which means that more than 90% of all 'with' commands should be converted properly automaticly!

Here is the current converted version of The Question: http://cf.ichan.ru/tmp/thequestion/

TODO:
# convert mp3 to ogg and back (using console utils, should be optional)
# renpy.display.motion.ATLTransform (aka 'show slavya at right')
# renpy.ast.If (aka 'if expr:')
# renpy.ast.Python (aka '$ expr')
# renpy.ast.Menu: more complex variations (something other than "each block is a Jump")
# renpy.text.extras.ParameterizedText (aka 'show text "qwerty" at truecenter')
# Styles (generate some CSS: message window, choice buttons, fonts)

I still need something like a
Code:
<move asset="img" x="50%" xanchor="50%"  />
to display character sprites at proper positions.

Guest

I'm currently working on python lines and 'if' conditions. Current
Code:
<var>
only allows to convert 3 types of strings:
Code:
$ x = 1
(set by value)
Code:
$ x = x + 1
(increase by 1)
Code:
$ x = x - 1
(decrease by 1)

Even things like this is almost unconvertable:
Code:
$ x = x + 100
(calling increase 100 times is a bad idea)
Code:
$ x = y
(there actually is a way to clone a var using only 3 given commands, assuming it is >0, using something like this:
Code:
x=0; z=0; while y!=0: {x++;z++;y--}; while z!=0: {z--;y++}
, which gives O(y) complexity of copying a var, lol)
Code:
$ x = x * 5
(yes, this <b>could</b> be done using addition and variable cloning:
Code:
y=x;z=5;x=0;while z!=0: {x=x+y; z--}
, but I don't even want to think of implementing such convertation)

There are also troubles with conditions. Simple one can be converted:
Code:
if x:
(ifvar="x", ifvalue="True")
Code:
if x == 5:
(ifvar="x", ifvalue="5")
Code:
if x != 5:
(ifvar="x", ifnot="5")

But even something simple is totally convertable:
Code:
if x > 5:

How I wish I could do more with vars...

Guest

Yeah, I totally know what you mean. The thing is, I can't just use JavaScript for that because &, > and < are not allowed in XML. So if I'd implement a "real" if, I'll have to use some other means of comparison. Maybe something like this:

<pre>
Code:
<if condition="x greater 5 and x isnt 8">
    <then>...</then>
    <else>...</else>
</if>
</pre>

So I'd have to write a parser for that. And that's why I didn't implement it yet, because, well, if I'd have to write a parser anyway, I could just write a parser for the whole language and don't use XML at all.

The alternative to writing a parser would be insanely verbose lisp-turned-XML-like stuff:

<pre>
Code:
<if>
    <condition>
        <and>
            <greater><x /><num>5</num></greater>
            <is-not><x /><num>8</num></is-not>
        </and>
    </condition>
    <then>...</then>
    <else>...</else>
</if>
</pre>

Or do you have a better idea?

Guest

Well, good alternative to python-turned-xml-like stuff and lisp-turned-xml-like stuff is <i>asm-turned-xml-like stuff</i> :3

For conditions like "if x*10 + 3 > 50: call good_end" it may be something like this:
Code:
<var action="set" name="tmp" value="{$x}" />
<var action="multiply" name="tmp" value="10" />
<var action="increase" name="tmp" value="3" />
<var action="is_greater" name="tmp" value="50" />
<sub scene="good_end" ifvar="tmp" ifvalue="True" />

Current engine can be very easily extended to support such things.
However, it may be hard for non-programmers to use this. But, actually not harder than using lisp-turned-xml-like stuff, i guess.

Note
Code:
value="{$x}"
part. Not sure if it is already supported, but it may be an elegant solution to x=y problem that i mentioned yesterday.

Guest

As for me, asm-turned-xml-like stuff is a rather good variant. It would not be too difficult to convert python math lines into blocks like in my comment above, using asm-like commands with 2 arguments, 1st of which is also used as a result holder.

If you think 2 arguments may be confusing for some situations, you can support 3 arguments variant as well, by adding optional 'lvalue' argument, which is equav to value of 'name' variable by default. This produces a more readable code is some cases, you can do stuff like "
Code:
if x==10 and y<x: call good_end
" with:
Code:
<var action="is_equal" name="tmp1" lvalue="{$x}" value="10" />
<var action="is_less" name="tmp2" lvalue="{$y}" value="{$x}" />
<var action="and" name="tmp1" value="{$tmp2}" />
<sub scene="good_end" ifvar="tmp1" ifvalue="True" />
Please, let me know what do you think about it.

Guest

Hi, sorry for the late reply.

I'm currently experimenting with using a little Lisp dialect for the engine. So far I like that approach. It would probably be very similar to the XML stuff but with much less verbosity and of course built-in variables.

I think in the mean time it wouldn't hurt to implement your idea in the current engine. I'm not sure when I'll add that feature, though.

Guest

Ok, this was easy and interesting to implement myself.
This pull request supports everything mentioned in my last posts: https://github.com/jsteinbeck/WebStory-E...l/11/files

* 'lvalue' optional argument, default value is value of 'name' variable
* 'value' is an optional argument, default value is 1
* "{$x}" is supported at 'value' and 'lvalue' options
* ariphmetic commands are: 'increase', 'decrease', 'multiply', 'divide', 'modulus'
* logics commands are: 'and', 'or', 'not'
* comparisons commands are: 'is_greater', 'is_less', 'is_equal', 'not_greater', 'not_less', 'not_equal'

Guest

Once this pull request is accepted, it unblocks me further development of rpy2wse :3

Current version 0.3 is now uploaded to http://cf.ichan.ru/tmp/thequestion/game/rpy2wse.rpy

The most wanted feature right now is 'xanchor' or something similar. I need it to show sprites at center/left/right/Position(...) positions.

Guest

Just merged your pull request. Thanks!

I like the ASCII art in your converter code, especially the "bug forbidden" symbol. Wink

Guest

Thanks a lot. Now, it is my turn to refresh long-time forgotten university knowledge of writing parsers.
Pages: 1 2 3 4