Recent content by Iron Sight

  1. Accessing Slots with Python at Compile Time

    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.
  2. Accessing Slots with Python at Compile Time

    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?
  3. Diplomacy 1.174 Prejudice Patch by Wulf/Iron Sight

    This is a patch for the "Prejudice" bug that causes female town/villager walkers to have men faces, just by clicking the drop-down selection...
  4. unassigned local variable & Error injecting code (among a few others)

    I wish I could tell, I tried using the source files of another mod (CTT), I suppose this is where the WRECK compiling comes from since I didn't install WRECK.
    I understand the lure of using Custom Troop Trees as a base for your mod, I mean, just about every M&B player wishes to create their own troops in game at some point. HOWEVER: Please understand, that very specific mini-mod (CTT) is not beginner friendly. CTT is almost completely written in Python, which is related to, but not the same as the language used in the ModSys. If you use CTT source as a base you should expect issues when using just about any other mod, as it is not very compatible friendly. Honestly, I would advise to start with just about any other base source for understanding how this all works. If you insist on using CTT's source as a base, you will be mostly on your own because you won't know how to explain which details are necessary to fix what is broken because their is a lot you won't realize you need to know. With all these things being said, if you are like me, you've just accepted the challenge, with your hard-headed ass, lol. But for real, CTT has a steeper learning curve than most other mod sources. So expect headaches, learning, confusion, learning, "start over remarks", learning, maybe some help, learning and taking plenty of breaks to keep from being confused with headaches. Regardless, all the best to you, good luck. Cheers! 07
  5. unassigned local variable & Error injecting code (among a few others)

    Hi.
    With that out the way, down to buisiness.

    1.)
    unassigned local variable <l.final_price_for_secondary_input[@1224979098644774926]> used by operation store_div in script.process_player_enterprise on line 48

    This is saying that the local variable ":final_price_for_secondary_input" isn't assigned before it's used. Being "assigned" is the same thing as initializing a variable in other coding languages. To fix it, simply put (assign, ":final_price_for_secondary_input", 0), at the top of the script it's in. Since you're using ModMerger, as evident by some of the issues further along, you can inject this code with ModMerger or just search for the script in the source and put the code in that way. This won't cause issues as is, that I know of, but It's good practice to initialize variables.

    2.)
    local l.unused declared but never used in script.game_get_troop_wage
    local l.unused declared but never used in script.debug_variables
    local l.unused_2 declared but never used in script.debug_variables
    local l.unused declared but never used in script.party_inflict_attrition

    This is saying that these local variables are declared (assigned / initialized) but not used in their respective script. To fix these, simple find the script they're in and use them. Since they aren't originally used you can use them however you like. I simply multiplied them by 1. For example:
    (val_mul, ":unused", 1), (val_mul, ":unused_2", 1), You can do this with either ModMerger or manually. These won't cause issues as is but again, good practice to keep everything clean.

    From here your situation is a bit confusing which is probably why the other repliers are suggesting you to go back and learn some of the basics of modding M&BW with the Module System. Your first spoiler indicates you are using W.R.E.C.K and your second spoiler indicates you are still using build_module.bat. It's also indicated that you're using ModMerger. All of these are good tools to use but you need to decide which compiler you will be using, either W.R.E.C.K or build_module.bat. You can use ModMerger with build_module.bat and the "copy_n_forget" version of W.R.E.C.K. You cannot use ModMerger with WRECK if you are using full integration of WRECK. My suggestion is to use the "copy_n_forget" version of W.R.E.C.K because it's faster, has better error detection in some ways, provides hints to fix missing commas, color to help differentiate the compiling process and my favorite reason, because it can use ModMerger. Whichever compiler you choose, stick with it and it only. After you've chosen a compiler and have looked over your code using the forum as a means to reference, then post again with the issues you're having and maybe someone will be more inclined to help you.
  6. Modding Q&A [For Quick Questions and Answers]

    Taragoth said:
    If I need to add 'not_in_party" to my module system as required by this modmerger code
    Code:
    pos = codeblock.FindLineMatching( (assign, "$talk_context", tc_ally_thanks) )
    codeblock.InsertBefore(pos, not_in_party ) #prevents player in party from being thanked by allies
    The where in the following code would I add it?
    Those lines are dictating where to add the code that's in the "codeblock" referred to as "not_in_party"

    So, it finds...
    Code:
    (assign, "$talk_context", tc_ally_thanks),
    and then adds the code that's in the "codeblock" named "not_in_party" in front of /or before the code that it's meant to look for.

    In the same file that this code is in will be something that looks like...
    Code:
    not_in_party = [ "code" "code stuff" "more code stuff"
    ]
    All the code within the brackets follow the same rules as any other code.
    So make sure that "not_in_party" is in the file and defined with the code you want to be executed when called.
    When modding, I only use modmerger files and have had to figure a lot of it out on my own.
    The modmerger usage post is good to start with https://forums.taleworlds.com/index.php/topic,320834.0.html but it doesn't cover advanced usage.

    If you want to move code from the modmerger file to your source files, look for...
    not_in_party = [ ]
    and copy all the code within the brackets and paste it before...
    (assign, "$talk_context", tc_ally_thanks)

    Hope this helped and good luck!
  7. Modding Q&A [For Quick Questions and Answers]

    SupaNinjaMan said:
    Iron Sight said:
    How do you put a right-facing curly bracket "{" to be displayed in a string? For example. ("number_count", "{1,2,3}"),
    I know how to put a left-facing curly bracket in... "} {}" or "{} }" but it doesn't seem to work the same for the right-facing type. I've also tried double curlies, triple curlies, enclosing both sides with {} and many other combinations but I can't get it to display correctly.
    I'm pretty sure it would be  ("number_count", "@{1,2,3}")
    I wished it was, but that displays the "@" and still says "{" is an "unrecognized token" but come to find out, "}" is acceptable even by itself. I dunno?!
    * and if I do double "{{" the first one is unrecognized but the second displays. I need to escape the { but I can't figure out what works here.
  8. Modding Q&A [For Quick Questions and Answers]

    How do you put a right-facing curly bracket "{" to be displayed in a string? For example. ("number_count", "{1,2,3}"),
    I know how to put a left-facing curly bracket in... "} {}" or "{} }" but it doesn't seem to work the same for the right-facing type. I've also tried double curlies, triple curlies, enclosing both sides with {} and many other combinations but I can't get it to display correctly.
  9. Modding Q&A [For Quick Questions and Answers]

    [Bcw]Btm_Earendil said:
    Iron Sight said:
    Looking for a lil direction on adding a troop to a scene, specifically the conversation scene.
    I used (add_troop_to_site, <troop_id>, <scene_id>, <entry_no>), but the troop didn't show.
    Is a trigger the best way to add a troop to a scene?
    Or can I use a script or even the condition or consequence blocks in dialog?
    Have a look here: https://forums.taleworlds.com/index.php/topic,317313.0.html
    Thank ya kindly!
  10. Modding Q&A [For Quick Questions and Answers]

    Looking for a lil direction on adding a troop to a scene, specifically the conversation scene.
    I used (add_troop_to_site, <troop_id>, <scene_id>, <entry_no>), but the troop didn't show.
    Is a trigger the best way to add a troop to a scene?
    Or can I use a script or even the condition or consequence blocks in dialog?
  11. Help with Arrays

    Well, I finished my array test/learning project a few days ago but got busy and didn't get to post what I did. I do plan to try to make some type of simple tutorial as I said I would, but it may take some time. (maybe this weekend? idk)
    Anyhow, here it is...
    Code:
    ("create_mercs_items_array",
    [	
    	(assign, ":offset", 0),														# starting "point" (slot) / distance between elements and starting point
    	(assign, ":element_counter", 0),												# a variable that's used to determine the size of an array
    		
    	(try_for_range, ":troop_id", mercenary_troops_begin, mercenary_troops_end),			                                # loops through the troop id ranges 
    		(gt, ":troop_id", -1),													# any troop id value greater than -1 passes this conditional operation
    		(assign, ":array_id", ":troop_id"),										        # assigns the array id variable value the same as the troop id value
    		(val_add, ":offset", 1),												# adds to offset to account for the slot needed to store the array id
    		(assign, ":array_id_slot", ":offset"),										        # assigns the array id slot variable value as the same as the offset value
    		(troop_set_slot, mercs_items_array, ":array_id_slot", ":array_id"),				                        # assigns a specific slot (array_id_slot) of the items array (mercs_item_array) with a value (array_id) 
    		(val_add, ":offset", 1),												# adds to offset to account for the slot needed to store the array size
    		(assign, ":array_size_slot", ":offset"),										# assigns the array size slot variable value as the same as the offset value
    			
    		(troop_get_inventory_capacity, ":inv_cap", ":troop_id"),						                # gets the inventory capacity of the troop that passed the conditional operation
    		(try_for_range, ":inv_slot", 0, ":inv_cap"),									        # a loop through the troop's inventory capacity
    			(troop_get_inventory_slot, ":item_id", ":troop_id", ":inv_slot"),			                        # gets the item id for each item in the troop's inventory according to its position in the troops capacity
    			(ge, ":item_id", 1),												# any item id greater than or equal to 1 passes this conditional operation
    			(val_add, ":element_counter", 1),									        # count how many items pass the conditional operation for use in the array's size property
    			(val_add, ":offset", 1 ),											# adds to offset for each item that passes the conditional operation to account for the slot needed to store each item's id
                            (assign, ":array_element_slot", ":offset"),								        # assigns the array element slot variable value the same as the offset value
    			(troop_set_slot, mercs_items_array, ":array_element_slot", ":item_id"),		                                # assigns a specific slot (array_id_slot) of the items array (mercs_item_array) with a value (array_id) 
    		(try_end),														# end of operations to try within the (inventory) loop 
    			
    		(troop_set_slot, mercs_items_array, ":array_size_slot", ":element_counter"),	                                        # assigns a specific slot (array_size_slot) of the items array (mercs_item_array) with a value (element_counter) 
    		(assign, ":element_counter", 0),											# assign(/reset) the element counter variable value 
    	(try_end),															# end of operations to try within the (troop) loop
    ]),
    What it does = creates inventory arrays for troops within the mercenary ranges, but can be tailored for any type of troop and even other things.

    I'm glad I finally took the time to learn this. I'm intrigued by both arrays and lists and will expand on what I have here.
    I know a lot of you know this stuff but I didn't and it's my first array offspring so please, don't hold back, tell me how ugly she is and that she'll never marry, lol. For real though, I plan to use this in the tut I want to put together, so how can I make it better? (not excluding things to consider when putting together the tut)
    As always ladies and gentlemen, thanks for your time and input.
    *note, I experimented with whether the game assigns imods when giving troops the items listed in module_troops.py, and it doesn't, just gives regular ol' items. And items with quantity, like arrows/bolts, are given at full capacity when given to a troop. So, there was no need to account for that info when putting together this array, which made it much simpler.
  12. Help with Arrays

    Ruthven said:
    If you are doing this only to learn about using arrays in warband, there might be easier tests you could do where you won't run into unexpected complications
    You are 100% correct, I could/should have chosen a simpler test but honestly once I realized how difficult it would be to use 3 types of info together in an array, with what I knew then, my interest was piqued and it was, "game on!", lol.

    Ruthven said:
    I'm sorry for the misunderstandings - but if you don't post any code, it's hard to know where your actual level of knowledge is at. You're here because you are (or were) lacking some info, we all have gaps in our knowledge and there's nothing wrong with that.
    No worries, misunderstandings happen, I understand that, lol. And I by no means am hostile in my replies. (just in case any of them were perceived as such)
    I intentionally don't post code unless I absolutely just can't figure out which operations are needed, or what order, or any other plethora of issues that arise when someone just gets "stumped". (ya won't get yur fix from me, ya bunch of code junkies! lol)
    I'm indifferent to whether anyone knows what "level" my knowledge is at but I do understand how teachers can use that info to better get through to students. But trust me, whatever you are trying to teach, will get through to me, one way or the other on my part.
    I'm most definitely here because I was lacking info, and specifically in this case wasn't really lacking the info but just failed to realize it, lol. If I'd have realized it the day before, I'd never have made this post and even if you'd have been the first person to reply, I'd have been done sooner. I'm definitely not afraid to ask about something I don't know.
    Also, I seen your "Explorer" mod. Amazing! (to say the least)
    And now on to learn about garbage collection!
  13. Help with Arrays

    Ruthven said:
    If you ask how to implement gameplay features, people with more experience will be able to help you find the best method. If you are asking for help with your techniques but not your implementation, all the answers we could ever provide may still not help you get closer to your goal. Reading your posts, I don't really understand your end goal. But here are some important bits of information:
    1: absolute biggest one: ID numbers are referenced internally by names with prefixes eg "itm_pike", "trp_looter", etc. These are what we use in the module system to reference IDs, you can use the real ID numeric instead, but then if you change the order of your source file, the ID will change and your code will cease working...
    2. Regular troop inventories are not saved the same as hero troop inventories, you will have to enable a line in module.ini for them to save at all.
    3. Its almost always easiest to store troop inventories by copying the entire inventory to another troop, instead of defining slots
    4. Right now your biggest barrier seems to be not being familiar with operations. Kal mentioned everything above: download lav's header_operations and start reading - skip to the relevant section to learn the item operations or better yet, start by reading the descriptions for each section to get a better overview of how modding itself works.

    It's great that you want to learn, but it seems like you're trying to dive right in to something without checking the depth (ha ha.) If you want to learn about arrays specifically or programming in general, there are probably better resources out there. If you tell us what you're actually trying to implement, maybe we can give some more relevant advice.
    The end goal is literally spelled out, IDK what else to say, just a project to help me understand how to use arrays with the items in a troops' inventory.
    1. I understand about the ID#'s but for some reason when first learning arrays, I completely missed them. Was a duh moment for sure. This revelation should have been indicated as rectifying one issue in an earlier post of mine, if it didn't then sorry but as of now, "I'm back in business." Meaning I've progress with my endeavor.
    2. I found this out after progressing but I didn't know about "a line in module.ini for them to save at all". Thanks!
    3.This I also found out once progressing but it's a work around for what I'm specifically trying to do to learn and defeats its purpose.
    4.This is definitely not my biggest barrier. I've been using Lav's header_operations for a long while now and have been scripting for a while but just never intentionally used arrays. I don't know how or what context brought this about, but ok.

    "it seems like you're trying to dive right in to something without checking the depth", who doesn't do this? I've been a mech head in the military for a while now and once I know a particular vehicle or appliance or whatever's theory of operation, I'm good to go. I can figure out how to repair, overhaul and improve, which I've done to just about every land vehicle in our arsenal, including appliance-like vehicles lol. I might've known some of what I know now if I didn't dive right in but I know I wouldn't have known everything I know now since I did.

    kalarhan said:
    Iron Sight said:
    That goes without saying really because that applies to just about anything that one person knows and another is learning

    you can do this:

    1) setup a test case
    2) use a logger to save the results on rgl_log.txt
    3) execute inside the game (runtime) and see what happens

    things to observe:
    1) what happens to the initial slots (say 0 to 10) as you go
    2) what happens with the entity slots array size as you use higher positions
    3) what happens with the savegame file (think file size)
    4) what happens with other entities of the same type
    5) what happens when you get around the possible limit (test positions before and after it), remember to also do (1) at the same time

    you will have plenty of tech doubts that may lack clear answer, have outdated information (game engine was updated over and over again in the last 15 years), etc. So if you learn how to do the above you will be able to answer those questions in a few minutes (once you get use to the script/trigger coding of MBScript).

    remember to enable EDIT MODE when doing tests.
    Thanks! Wilco!

    Since the absence of information seems to breed misunderstanding... I'm almost done with my project, well, until I found out about "a line in module.ini" so now I'll have to check in on that but still, just about done. Thanks for yalls input!

    *Edit: Ok, so I enabled the game to save troops inventory... why isn't this done by default?(rhetorical) Are there bugs associated with it's use? (unrhetorical)
  14. Help with Arrays

    Rodrigo Ribaldo said:
    People here are primarily motivated to help other people when they are serious about accomplishing something, and some may be a bit disappointed by random questions.
    Please understand that and don't get offended.
    I understand that. That goes without saying really because that applies to just about anything that one person knows and another is learning. At the same time I'm not gonna curtail the "method of my madness" just because some people can't fathom my means. If they wanna answer, then answer, if they don't wanna, then don't. Makes no matter to me. I promise I won't be disappointed if I do or don't understand why they will or won't answer. I'm one of the last persons to be offended by something someone wrote about something I like to do for fun knowing that they know nothing about me. If we all only really knew each other... but since we don't, I'm a very reasonable person who likes to joke around, once I know ya, but one thing I don't do, is assume things about people without proof, nor do I tolerate it. I also like to type a lot late at night while I'm racking my brain over the things I'm tryin to do with this script stuff. lol
  15. Help with Arrays

    kalarhan said:
    Instead of worrying about weird magic numbers...
    Rodrigo Ribaldo said:
    Or better yet, concentrate on questions that are relevant to your goal, unless you anticipate a modding trivia quiz in the near future.
    Were these statements really necessary? I can't ask questions? Who said I was worried, and who knows better than me what I should concentrate on? My life is in order, this is a hobby and I just like to know things. Come on now. But I do like the "check out this thing" thing.
Back
Top Bottom