Results 1 to 30 of 33

Thread: Newbie scripting question [LevyScript]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Newbie scripting question [LevyScript]

    I'm a fairly experienced coder whose just recently gotten into MT2TW modding and the first thing I've decided to try and cook up is a Levy Script (sortof a counterpoint to Klink's garrison script. The main roadblock I'm running into is a lack of understanding of how to get at certain info thats necessary for making the script even operate.

    I've provided the pseudocode below in the hoped of getting some feedback as to which functions and grammar I'll need to accomplish the following;

    ;::::Start Test Levy Script;::::
    declare_counter muster_isbuilt
    set_counter muster_isbuilt 0
    ;;;;;[[Pseudo Code in question]]
    ;::::Check if Muster_call [building] is built in a particular settlement [London]
    ;::::if yes [muster_isbuilt == 1], get the settlement's population [int]
    ;:::: get settlement's tech level (wall) [int]
    ;:::: get info on settlement building types [bool + int]
    ;:::: get info on settlement governor [bool + int]
    ;:::: ??Get info on neighboring settlements?? [bool + int]
    ;:::: Spawn units based on this info

    ;::::Example Usage:
    ;::::[if Building A exists in London]
    ;:::: [settlement_pop = Settlement_pop London]
    ;:::: [if Building B exists in London]
    ;:::: [B_exists = 1]
    ;:::: [if Governor Z has trait1]
    ;:::: [Governor_has_trait1 = 1]
    ;:::: [if neighboring region [Sherwood] belongs to player1]
    ;:::: [neighboring_pop = Settlement_pop Sherwood]
    ;::::[London_muster_score = settlement_pop/1000 + (B_exists * 100) + (Governor_has_trait1 * 100) + (neighboring_pop/2000)
    ;::::[if London_muster_score > 0 && < 5000]
    ;:::: [create_unit London, Peasants, num 4, exp 0, arm 0, wep 0]
    ;::::
    ;::::

    If anyone has any ideas as to which functions I cna use to get even a bit of this done, as well as some syntax examples, I'd be eternally greatful.

  2. #2
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Newbie scripting question [LevyScript]

    Haha yes, you'll be frustrated by M2 scripting before long
    Basically, something like you want to do is much, much more difficult than you'd expect with M2 scripts. Some of the problems:
    - no real variables
    - no counter-to-counter or counter-to-exposed comparison (only counter-to-constant)
    - no functions, only commands and conditions
    - conditions are boolean only
    - most conditions have a game object as trigger requirements and thus only work in monitor_event
    - no maths (well except for adding and subtracting and even then, only counter + constant)

    Doing what you want to do requires a lot of creative thinking and compromises. I'm working on something similar and it's really hard to factor in a lot of the game state because you can't use variables.
    You can design a few workarounds by using while loops, gigantic if-lists and such, but it's really not pretty.

  3. #3

    Default Re: Newbie scripting question [LevyScript]

    Well, I don't mind doing a lengthy workaround, I'm mainly concerned with whether its possible to get the info I want. For instance, Klink' script does something like this;

    declare_ counter Dongola_lev
    set_counter Dongola_lev 1
    monitor_event SettlementTurnStart SettlementName Dongola
    and SettlementBuildingExists = wooden_wall
    set_counter Dongola_lev 2
    end_monitor

    Basically, where can I find a list of conditions that I can use in monitor events like SettlementBuildingExists?

    I'm not afraid of fat if lists. :)

  4. #4

    Default Re: Newbie scripting question [LevyScript]

    you need to refer to the Docudemon files v 1.2

    https://forums.totalwar.org/vb/showthread.php?t=83119

  5. #5

    Default Re: Newbie scripting question [LevyScript]

    Yup, been skimming them since last night. One thing I've noticed that doesn't exist is anyway to find out the actual population of a settlement, I've found equivalents for nearly everything else. Any clues?

  6. #6
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: Newbie scripting question [LevyScript]

    Yeah it's a minor problem. You can only use the settlement level via building exists

  7. #7

    Default Re: Newbie scripting question [LevyScript]

    Check the Mod Chat forum, and download Caliban's Docudemon files v1.2.

    The main problem in regards to your script is that you need to check for all your conditionals all at once. In other words, you can't be like:

    if building_A exists
    ...if building_B exists
    ......do something
    ...end_if
    ...if building_C exists
    ......do something else
    ...end_if
    end_if

    The reason for that is that almost all conditionals consume outside data, data supplied by EVENTS. If you read the events document in docudemons, you will see. Events, such as SettlementTurnStart, supply all of the content that the conditionals then consume and use. There is no:

    if building_A exists in settlement ABC. It's only

    if building_A exists.

    How is the script going to know which settlement? Only by using this conditional in conjunction with an event that supplies the settlement name.

    That's the basic framework that you have to work around. It's far from a full-fledged scripting language. Now given this limitation, you can still create some rather sophisticated programs. And also let me point out that a few conditionals don't need to be supplied with an event's data, they are entirely stand-alone. In the conditions file, you will see those conditions as ones having the I_ prefix, e.g. I_SettlementExists. Ideally, all of conditionals should have I_ formats, (poke Caliban), as that would untie our hands in unbelievable ways. But for now, we have to be satisfied with those that already exist. Hopefully I still haven't detracted you from your project, because you can still do it, just need to work with the system here. Your hands become untied if you use counters (proto-variables) cleverly, if you use if() and while() commands in clever ways.
    Last edited by SigniferOne; 04-18-2007 at 18:32.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO