Editing Creating Custom Events

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 19: Line 19:


'''core/components/event/conditions/core.py'''   
'''core/components/event/conditions/core.py'''   
 
<code>python
    python
...
    ...
def always_true(self, game, condition):
    def always_true(self, game, condition):
     print "This will always return True!"
     print "This will always return True!"
     print "    Condition:", condition
     print "    Condition:", condition
     return True
     return True
    ...
...
</code>


Notice that ''every'' condition must have these two parameters:   
Notice that ''every'' condition must have these two parameters:   
Line 36: Line 36:
The <code>condition</code> parameter will give you access to the condition that was defined in the map file. This is good if you want to check for other parameters that your condition might require.
The <code>condition</code> parameter will give you access to the condition that was defined in the map file. This is good if you want to check for other parameters that your condition might require.


Here's an example of what you might get back as a condition you define in [http://www.mapeditor.org Tiled]:   
Here's an example of what you might get back as a condition you define in [Tiled](http://www.mapeditor.org):   
 
<code>python
    python
>>> condition
    condition
{'id': 3,
    {'id': 3,
'operator': 'is',
    'operator': 'is',
'parameters': '1',
    'parameters': '1',
'type': 'always_true',
    'type': 'always_true',
'x': 1,
    'x': 1,
'y': 3}
    'y': 3}
</code>


After creating your condition, you can now open up [Tiled](http://www.mapeditor.org) and create a new event with your condition!
After creating your condition, you can now open up [Tiled](http://www.mapeditor.org) and create a new event with your condition!
Line 57: Line 57:


'''core/components/event/actions/core.py'''   
'''core/components/event/actions/core.py'''   
 
<code>python
    python
...
    ...
def say_hello(self, game, action):
    def say_hello(self, game, action):
     print "Hello World!"
     print "Hello World!"
     print "    Action:", action
     print "    Action:", action
    ...
...
</code>


Notice that ''every'' action must have these two parameters:   
Notice that ''every'' action must have these two parameters:   
Line 74: Line 74:


Here's an example of what an action might look like:   
Here's an example of what an action might look like:   
 
<code>python
    python
>>> action
    >>> action
('say_hello', 'Hi', '3', 1)
    ('say_hello', 'Hi', '3', 1)
</code>


After creating your action, you can now open up [http://www.mapeditor.org Tiled] and include it in your event!
After creating your action, you can now open up [http://www.mapeditor.org Tiled] and include it in your event!


http://i.imgur.com/WlKvYkL.png
[http://i.imgur.com/WlKvYkL.png]


Now run Tuxemon and go to your map and see what happens! You should see the console printing everything you defined in your action and condition!
Now run Tuxemon and go to your map and see what happens! You should see the console printing everything you defined in your action and condition!

Please note that all contributions to Tuxepedia are considered to be released under the Creative Commons Attribution-ShareAlike (see Tuxepedia:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)