Mercurial > parpg-source
comparison systems/scriptingsystem.py @ 171:565ffdd98d68
Added math functions to the scripting system functions.
author | Beliar <KarstenBock@gmx.net> |
---|---|
date | Sun, 26 Feb 2012 01:24:33 +0100 |
parents | ed24962cdf5e |
children | 3abd31885f0f |
comparison
equal
deleted
inserted
replaced
170:0296f5f74a0f | 171:565ffdd98d68 |
---|---|
11 # You should have received a copy of the GNU General Public License | 11 # You should have received a copy of the GNU General Public License |
12 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
13 | 13 |
14 from collections import deque | 14 from collections import deque |
15 from copy import deepcopy | 15 from copy import deepcopy |
16 import math | |
16 | 17 |
17 from parpg.bGrease import System | 18 from parpg.bGrease import System |
18 | 19 |
19 class Script(object): | 20 class Script(object): |
20 """Script object""" | 21 """Script object""" |
81 their behavior. | 82 their behavior. |
82 """ | 83 """ |
83 | 84 |
84 def __init__(self, commands, actions): | 85 def __init__(self, commands, actions): |
85 """Constructor""" | 86 """Constructor""" |
86 self.funcs = {} | 87 self.funcs = {} |
88 self.common_funcs = { | |
89 "sqrt":math.sqrt, | |
90 "log":math.log, | |
91 } | |
87 self.vals = {} | 92 self.vals = {} |
88 self.commands = commands | 93 self.commands = commands |
89 self.actions = actions | 94 self.actions = actions |
90 self.game_state = None | 95 self.game_state = None |
91 self.reset() | 96 self.reset() |
108 self.game_state.getObjectDictOfMap( | 113 self.game_state.getObjectDictOfMap( |
109 self.game_state.current_map_name) | 114 self.game_state.current_map_name) |
110 ) | 115 ) |
111 self.funcs.clear() | 116 self.funcs.clear() |
112 self.funcs.update(self.game_state.funcs) | 117 self.funcs.update(self.game_state.funcs) |
118 self.funcs.update(self.common_funcs) | |
113 for condition_data in self.conditions: | 119 for condition_data in self.conditions: |
114 condition = condition_data[0] | 120 condition = condition_data[0] |
115 script_name = condition_data[1] | 121 script_name = condition_data[1] |
116 if not self.scripts.has_key(script_name): | 122 if not self.scripts.has_key(script_name): |
117 return | 123 return |