My solution does work. Just replace the unit.Name= line at the bottom of the function with unit.Name=args.source_unit.Name+" "+args.unitname+" "+unitcount; And in the after_perform=add_unit@ { }, you need to write unitname: “name of the unit” between the braces. so for archers: after_perform=add_unit@ { unitname: “bowmen” } I think there is another way if you don’t like that, but this one has less script editing. Abi From: abigail prescott Sent: Thursday, August 22, 2013 8:04 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: Houston, we got a problem , Abi help please Ah, I’ve spotted the problem, and also a stupid mistake of mine. When using units with spaces in the name, if the name isn’t enclosed in quotes, you need to replace spaces with underlines, like in flags. So it would be var light_cavalry=shared.CreateUnit(“light cavalry”). Does that make sense? My mistake is a very stupid one which I’m quite annoyed about making. I’m quite sure I know how to fix it, but I’m going to test it first so if it doesn’t work, I can come up with something else and give you the simplest solution. It is definitely fixable and should only need editing a few lines. Basically, at the moment, the script will work, but it’ll call all units bowmen. My only defense is that in my original idea for renaming that line made sense and I’ve only been testing with archers and hadn’t noticed. Abi From: Allan Thompson Sent: Thursday, August 22, 2013 7:43 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: Houston, we got a problem , Abi help please Hi Abi, Good for you! Congrats on passing. I have a problem. I must be doing something wrong, but I can’t figure out what it is. Below, with the part minus the light cavalry removed, it works great for the archers. I tried to copy the example for light cavalry, but it is saying there is an error, and I am clueless. I am wondering if just numbering the units as is might be easier? Maybe that is something that I can do a bit easier? I am just not getting the hang of this thing. Thanks for any help. What I got is below. function add_unit(args) { // just paste the rest of the if blocks as shown above below this comment but above the rest of// the code. // bit you need to copy and edit starts here. if (args.skill.IndexedName=="recruit archers") // change bit in quotes to name of skill that recruits the unit you want, so recruit light infantry to do this for light infantry. { var archer = shared.CreateUnit("archers"); shared.Map.AddUnit(archer, args.target_tile.X, args.target_tile.Y); var unit = archer; // replace the word archer with the name of the unit, I think if it isn't in quotes you should// use underscores instead of spaces. } // bit you need to copy and edit starts here. if (args.skill.IndexedName=="recruit light cavalry") // change bit in quotes to name of skill that recruits the unit you want, so recruit light infantry to do this for light infantry. { var light cavalry = shared.CreateUnit("light cavalry"); shared.Map.AddUnit(light cavalry, args.target_tile.X, args.target_tile.Y); var unit = light cavalry; // replace the word archer with the name of the unit, I think if it isn't in quotes you should// use underscores instead of spaces. } // rest of code. var units = shared.Map.AllUnits; var unitcount=0; for (i=0; i<units.length; i++) { if (units[i].Type==unit.Type) { unitcount=unitcount+1; } } unit.Name=args.source_unit.Name+" bowmen "+unitcount; } From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of abigail prescott Sent: Thursday, August 22, 2013 2:31 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: Houston, we got a problem , Abi help please Sorry about not replying earlier, but I’ve been at the beach all afternoon, I hope you haven’t been struggling too long. If I’m understanding you correctly, then that is right and should work. Remember that for each unit you want this to work for, you need to change the recruit skill file for that unit (so the recruit light infantry for the light infantry unit and the recruit light cavalry skill file for the light cavalry incase I didn’t explain that well enough), and delete the summon= line and add the after_perform=add_unit@ { } line. Thanks for making it official. This is another good thing to add to today. I got my gcse results (GCSEs are exams you take in year 10 and 11, though it’s been changed now so it’s only in year 11) and I managed to pass everything! Good luck with the script. Abi From: Allan Thompson Sent: Thursday, August 22, 2013 3:56 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: Houston, we got a problem , Abi help please Wait a minute, I think I get it. That bit to copy is all part of the same text file that is in the scripts folder, under your named folder. So I should copy that bit for every recruit skill and it goes all into the same file. Is that correct? I just tried it with archers, and it worked awesome! You are now officially amazing! Thanks so much! I will get working on this and hopefully I can have it all done soon. al From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of Allan Thompson Sent: Thursday, August 22, 2013 10:39 AM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Houston, we got a problem , Abi help please Ok, I am just not understanding what goes where. Let me do this, and show you what I am thinking and you correct where I am screwing up. In the recruit unit skill, in this case, archers. I put this in: after_perform=add_unit@ { } I make sure to delete the summon= flag. Ok, now the rest goes into the scripts folder, under the one with your name. What I don’t understand is the changing of the skill name and unit. Do I make a list of all the units and recruit skills in this same code? Or does that actually go to the recruit skill? function add_unit(args) { } if (args.skill.IndexedName=="recruit archers") { var archer = shared.CreateUnit("archers"); shared.Map.AddUnit(archer, args.target_tile.X, args.target_tile.Y); var unit = archer; . var units = shared.Map.AllUnits; var unitcount=0; for (i=0; i<units.length; i++) { if (units[i].Type==unit.Type) { unitcount=unitcount+1; } } unit.Name=args.source_unit.Name+" bowmen "+unitcount; } From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of abigail prescott Sent: Thursday, August 22, 2013 2:59 AM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! I’ve just sent a reply to the reloaded conversation with a link to a new, updated version of the function with numbering. Basically, you put that after_perform bit in every recruit skill file that you want to use this skill. I also forgot to mention that you have to delete the summon= line because the function also handles creating the unit. Then you create a folder with my name in the scripts folder as you said, and the file doesn’t have to be changed to js, it works just as well as .txt. It’s also easier to edit if you just have notepad, as you can just open it instead of having to remember to edit it. You don’t need a separate file for each unit. The if (args.skill.IndexedName==”recruit unit”) line checks to see what skill is being used and uses the corresponding unit. You just need to make sure that you paste the block I’ve indicated in the updated function in the right place (which is also indicated) and change all references of archer to the corresponding unit. So you would change the “recruit archers” to “recruit light infantry” for the function to work with the recruit light infantry skill. Hope that makes sense, and I’ve commented the function so it’ll give you a better idea of what to do with each bit of code. Abi From: Allan Thompson Sent: Thursday, August 22, 2013 2:02 AM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! Hi Abi, I am a little lost. So there is this line of code in this particular email. That is all that goes into the recruit skills? The other stuff, you said that goes into the scripts folder? I am looking at it, and what I see is Ian and Craig’s name there. I guess I would make a folder with your name and put that code in, right? It looks like it is named XX.js, so what should I name the file? What are ARGS? I think I understand enough to switch out the skill name and the unit type. Do I have to make a separate script.js file for each unit/recruit skill? Sorry, like I said, bear, space shuttle, nothing good can come from such a combo, lol. Thanks for being patient, al From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of abigail prescott Sent: Wednesday, August 21, 2013 4:36 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! I’ve got it! At least, I’ve got the structure naming bit, not the numbering bit. But now it’ll name your archers from Camelot Camelot bowmen. It’s an after_perform now because that worked better. In all recruiting skill files: after_perform=add_unit@ { } I’ll send a link for the function in a bit, but windows explorer seems to have frozen, so I don’t know how long that’ll take. Do you understand how to add if blocks? I’ve only done archers to demonstrate because I haven’t played the latest warlords version yet (though I’m quite excited about it and probably will in a few minutes) and it sounds like there are a lot of units to add. Abi From: abigail prescott Sent: Wednesday, August 21, 2013 7:32 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! I think it might be possible, but I’ll do some testing first because the idea I’ve got seems like it’ll depend on a few factors which will overcomplicate things. In the unit file: after_create=name_unit@ { } In a file in the scripts folder: function name_unit(args) { if (args.unit.Type==”archer”) { args.unit.Name=”bowman”; } } This will name the units without the structure and numbering and I’ll get back to you if I can get any further on that. For the other units, you can copy and paste the block starting at if ( and ending at the first right-brace and change the “archer” to “whatever the unit type is” and the “bowman” to “name of unit”. Hope that makes sense. If not, just ask me to explain what’s confusing you. Lol. I just like looking at examples and messing around to see what works (and bombarding Ian with questions, of course), but I’ve done some programming before so I understand the basic concepts. I’m going to start computing alevel this year too, so hopefully I can learn some more. Abi From: Allan Thompson Sent: Wednesday, August 21, 2013 6:50 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! Hi, Wow, that is awesome! I am constantly amazed at people who can make sense of this stuff. So, would this be like a skill kind of thing? I really am clueless. I can program, like a bear can fly a space shuttle. Both would most likely end in disaster, lol. Would it be possible to even include the name of the recruiting structure? For instance, if the number thing was doable, and if you had a city named Camelot, and it made a unit of archers, then could it be possible to have that unit pop out as… 1st Camelot bowmen Is it even possible? I really don’t know. Thanks. I want to try it. Where would I put it? al From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of abigail prescott Sent: Wednesday, August 21, 2013 1:21 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! If by autonaming you mean the unit is given a name as it is created, you could do it with an after_create script. I’m not sure if there’s a way to count how many of each type of unit exist though, so I don’t know about the numbering. Apart from that, I think it would be after_create=name_unit@ { } and the name_unit function would be: function name_unit(args) { args.unit.Name=”name”); } to give different names depending on type you would add in an if statement: function name_unit(args) { if (args.unit.Type==”archer”) { args.unit.Name=”bowman”; } } Not sure if that helps, but that’s all I can think of that sounds like what you want. Abi From: Allan Thompson Sent: Wednesday, August 21, 2013 6:04 PM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! Hi Carlos, Thanks for the kind words in your other email. I think you are right. I had wanted to do that, but I wasn’t sure how all the others would like having units pop up already ai controlled. With so many units on the board though, it becomes really hard to keep track, and sometimes you just want to deal with one battle at a time. What would be ideal is if there was an option that , upon recruitment, the player is asked if they want to start with ai on or off. Maybe that would be a bit much much, but I guess it is just as easy to hit the control+shift +a combo. Also, an auto naming of units would be excellent. With the experience points thing, it is fun, but it is also crazy trying to keep track of them. I would simply have a document out to keep track of the units, but that gets tedious as well. With an auto naming feature they would pop out with names/numbers for easier tracking. No idea how that would happen on the coding side, or if it is super difficult, etc. My naming conventions are feature a number (1st, 2nd, 3rd, etc) plus these… Infantrys I call legions Archers I call bowmen Cavalries I call horse Catapults I call artillery And like Michael, I rarely name the special characters unless ther is more then one of them. Although sometimes I name them after political leaders just for kicks, or famous generals, or whatever, I use a theme, grin. I will put ai control into all the units. I think that is probably the best way to deal with it for now, so people can choose for themselves.Thank you for suggesting that. al From: ian-reeds-games-bounce@xxxxxxxxxxxxx [mailto:ian-reeds-games-bounce@xxxxxxxxxxxxx] On Behalf Of Carlos Macintosh Sent: Wednesday, August 21, 2013 7:29 AM To: ian-reeds-games@xxxxxxxxxxxxx Subject: [ian-reeds-games] Re: warlords, prepare to conquer! This is a weakness of mine, not you, but still, I thnk we should be able to toggle AI controlled on our units. That way if you want to attack something you can focus on recruiting the units and leave the moving to the AI. Or if you want to deploy your forces intelligently you can do that too. It’s a problem I have with any map where you recruit things. Because thigs get really hectic really fast when you have 20, 30, even 40 units and you have to keep track of all of them.