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