Author Topic: Can some help me with this code.  (Read 1902 times)

Sunhawken

  • Guest
Can some help me with this code.
« on: October 24, 2007, 11:37:48 PM »
So whats wrong with my code.
I put it in module_triggers.py
I'm trying to make a party spawn for a specific faction. And that party will spawn from thats factions towns.


Code: [Select]
# Protecters of Adule
 (5.7, 0, 0.0, [ (try_for_range,":town_no",towns_begin, towns_end),
                 (party_slot_eq,":town_no",slot_town_lord,"fac_kingdom_7"),
                 (faction_slot_eq,"fac_kingdom_7",":town"),
                 (try_for_parties,":party_no"),
                 (store_faction_of_party,"fac_kingdom_7",":town_no"),
                 (store_num_parties_created,reg(10),"pt_kingdom_7_protectors"),
                 (lt,reg(10),num_max_zendar_manhunters),
                 (store_num_parties_of_template, reg(2), "pt_kingdom_7_protectors"), (lt,reg(2),10)],
              [   (try_for_range,":town_no",towns_begin, towns_end),
                  (party_slot_eq,":town_no",slot_town_lord, "fac_kingdom_7"),
                  (faction_slot_eq,"fac_kingdom_7",":town"),
                  (try_for_range,":town_no",towns_begin, towns_end),
                  (set_spawn_radius,0),(spawn_around_party,":town","pt_kingdom_7_protectors"),
                  (try_end),
                  (try_end)]),


Offline Winter

  • I am Tek Jansen!
  • Administrator
  • *****
  • Posts: 476
  • MBX Forum owner
    • View Profile
    • Street of Eyes: The Writing of Ryan A. Span
Re: Can some help me with this code.
« Reply #1 on: October 25, 2007, 04:52:46 AM »
This is a warning. Post questions to Discussion, where people, y'know, DISCUSS modding. Not to a board for TUTORIALS.

Offline fujiwara

  • Master
  • *****
  • Posts: 858
    • View Profile
Re: Can some help me with this code.
« Reply #2 on: October 25, 2007, 07:21:49 AM »
Two things jump out at me:

1) In the first ops block, you have Two (2) dangling nested try blocks. How is the engine to know where those end?

2) the local :town is referenced without assignment first in the first block.

A better way to do what you're trying to do would be this:

Code: [Select]
(5.7, 0, 0.0,
[
     (store_num_parties_of_template,reg2,'pt_kingdom_7_protectors'),
     (lt,reg2,10),
     ],
[
     (call_script,'script_get_random_faction_town','fac_kingdom_7'),
     (assign,':town',reg0),
     (set_spawn_radius,0),
     (spawn_around_party,':town','pt_kingdom_7_protectors'),
     ]
),

This can be easily expanded to encompass all factions, but that is left as an exercise for the reader.

The horses tend to get their legs caught in the catapult rather than being properly launched.