So i'm creating a tile based strategy game. each tile is marked by a waypoint (basically it's xpos and ypos). The path is a list of these waypoints that each unit moves between. Obviously there is a bit more to it than that, but that's the general overview.
Here's my problem:
I have a generator that determines all the possible routes a unit can take, records them and picks the most efficient route. However that route can have infinite changes of direction. Now usually i'd use a for loop to account for an infinite combination of N, S, E, W moves, but ATL doesn't accept for loops and it's like, nor can you alter variables passed to it in any meaningful way like you can in functions. This effectively limits your transforms to a pre-determined number of changes in direction since you can't put any type of generator in them.
Here's my question:
Is it possible to use a python function to instantiate an ATL transform and return it?
Can a python function create and return an ATL transform?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Evildumdum
- Regular
- Posts: 191
- Joined: Sun Jan 18, 2015 8:49 am
- Projects: ApoclypseZ
- Contact:
Can a python function create and return an ATL transform?
"If at first you don't succeed, try hitting it with a shoe."
Re: Can a python function create and return an ATL transform
I don't see why not, an ATL transform is a Class so once instantiated should be able to be returned as normal.
If we are what we repeatedly do, then good coding is not an act, but a habit
Re: Can a python function create and return an ATL transform
https://www.renpy.org/doc/html/atl.html
https://www.renpy.org/doc/html/trans_tr ... #Transform
https://github.com/renpy/renpy/issues/525
You can use a curried function as a Transform function, and pass values into that:The Python equivalent of an ATL transform is the Transform() displayable. There is no way to create an ATL transform programmatically.
https://www.renpy.org/doc/html/trans_tr ... #Transform
https://github.com/renpy/renpy/issues/525
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: Can a python function create and return an ATL transform
It's not clear for me what you want to do exactly, but I'd share my knowledge.
This is not a well known thing, but transform IS pure python function itself. https://www.renpy.org/doc/html/trans_tr ... transforms
If you search defined objects in ren'py, you'll notice all transforms are just python functions.
So you can define transforms as python function. If you want to include ATL in a function, do something like:
Also, there's easier way to implement python function in ATL.
Though it may have trouble to control when to execute/update transform, I'm not sure before testing.
(Actually, there're more other ways to do things, but I don't know what's best for your code)
PS: and I wish ren'py supports for loop in both labels and transforms.
This is not a well known thing, but transform IS pure python function itself. https://www.renpy.org/doc/html/trans_tr ... transforms
If you search defined objects in ren'py, you'll notice all transforms are just python functions.
So you can define transforms as python function. If you want to include ATL in a function, do something like:
Code: Select all
def sample_python_transform(displayable):
new = transform_defined_in_atl(displayable)
#do other things
return new
Code: Select all
init python:
def func():
#do something
return x
transform test():
xpos func() #it's execute the func then returns x when this transform is shown.
(Actually, there're more other ways to do things, but I don't know what's best for your code)
PS: and I wish ren'py supports for loop in both labels and transforms.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot]