but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with NML; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.""" from nml import expression, generic, global_constants from nml.actions import action2, action2random, action2var, action2var_variables from nml.ast import base_statement, general var_ranges = {"SELF": 0x89, "PARENT": 0x8A} # Used by Switch and RandomSwitch switch_base_class = action2.make_sprite_group_class(False, True, True) class Switch(switch_base_class): def __init__(self, param_list, body, pos): base_statement.BaseStatement.__init__(self, "switch-block", pos, False, False) if len(param_list) < 4: raise generic.ScriptError( "Switch-block requires at least 4 parameters, encountered " + str(len(param_list)), pos) if not isinstance(param_list[1], expression.Identifier): raise generic.ScriptError( "Switch-block parameter 2 'variable range' must be an identifier.", param_list[1].pos) if param_list[1].value in var_ranges:
(global_constants.item_names, global_constants.item_to_id) ]) return action3.parse_graphics_block(self.graphics_block, item_feature, wagon_id, item_size, True) def __str__(self): ret = "livery_override({}) {{\n".format(self.wagon_id) for graphics in self.graphics_block.graphics_list: ret += "\t{}\n".format(graphics) if self.graphics_block.default_graphics is not None: ret += "\t{}\n".format(self.graphics_block.default_graphics) ret += "}\n" return ret graphics_base_class = action2.make_sprite_group_class(False, False, True) class GraphicsBlock(graphics_base_class): def __init__(self, graphics_list, default_graphics, pos): base_statement.BaseStatement.__init__(self, "graphics-block", pos, in_item=True, out_item=False) self.graphics_list = graphics_list self.default_graphics = default_graphics def pre_process(self): for graphics_def in self.graphics_list: graphics_def.reduce_expressions(action2var.get_scope(item_feature))
def get_action_list(self): return [] def __str__(self): ret = "template {}({}) {{\n".format( str(self.name), ", ".join([str(param) for param in self.param_list])) for sprite in self.sprite_list: ret += "\t{}\n".format(sprite) ret += "}\n" return ret spriteset_base_class = action2.make_sprite_group_class(True, True, False, cls_is_relocatable=True) class SpriteSet(spriteset_base_class, sprite_container.SpriteContainer): def __init__(self, param_list, sprite_list, pos): base_statement.BaseStatement.__init__(self, "spriteset", pos, False, False) if not (1 <= len(param_list) <= 2): raise generic.ScriptError( "Spriteset requires 1 or 2 parameters, encountered " + str(len(param_list)), pos) name = param_list[0] if not isinstance(name, expression.Identifier): raise generic.ScriptError( "Spriteset parameter 1 'name' should be an identifier",
(at your option) any later version. NML is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with NML; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.""" from nml import expression, generic from nml.actions import action2, action2var, action2production from nml.ast import base_statement produce_base_class = action2.make_sprite_group_class(False, True, True) class ProduceOld(produce_base_class): """ AST node for a 'produce'-block, which is basically equivalent to the production callback. Syntax: produce(name, sub1, sub2, sub3, add1, add2[, again]) @ivar param_list: List of parameters supplied to the produce-block. - 0..2: Amounts of cargo to subtract from input - 3..4: Amounts of cargo to add to output - 5: Run the production CB again if nonzero @type param_list: C{list} of L{Expression} """ def __init__(self, param_list, pos): base_statement.BaseStatement.__init__(self, "produce-block", pos, False, False)