Accessing Slots with Python at Compile Time

Users who are viewing this thread

I know we can use Python to set-up the information we need at Compile time then run scripts to insert that information into slots at Runtime but
just in case I've missed it, did anyone ever access slots directly with Python at Compile Time?
 
Solution
No. You can access slots only when game starts. But you can generate warband script in python.

Python:
test = []
for i in xrange(1030):
  variable = ":var" + str(i)
  test.append((display_message, "@"+variable+"testing"))
  test.append((assign, variable, 1))
  test.append(try_begin)
  test.append((neq, variable, 1))
  test.append((display_message, "@"+variable+"failed"))
  test.append(try_end)

scripts += [
  ("cf_test", test),
]
No. You can access slots only when game starts. But you can generate warband script in python.

Python:
test = []
for i in xrange(1030):
  variable = ":var" + str(i)
  test.append((display_message, "@"+variable+"testing"))
  test.append((assign, variable, 1))
  test.append(try_begin)
  test.append((neq, variable, 1))
  test.append((display_message, "@"+variable+"failed"))
  test.append(try_end)

scripts += [
  ("cf_test", test),
]
 
Last edited:
Upvote 1
Solution
Could you provide an example of what you're looking to do?
Looking to access (insert information into) slots at Compile time.
No. You can access slots only when game starts. But you can generate warband script in python.

Python:
test = []
for i in xrange(1030):
  variable = ":var" + str(i)
  test.append((display_message, "@"+variable+"testing"))
  test.append((assign, variable, 1))
  test.append(try_begin)
  test.append((neq, variable, 1))
  test.append((display_message, "@"+variable+"failed"))
  test.append(try_end)

scripts += [
  ("cf_test", test),
]
I figured as much. I already know how to generate various things at Compile time. Thanks though.

Was just a question to see if anything had changed.
 
Upvote 0
Back
Top Bottom