21.10.2020 13:48
I tried this, but received EresseaConstants class or variable doesn't exist.That seems about right. getBuildingType.getMaintenance((EresseaConstants.I_USILVER).getAmount is a little more concise.
interface Interpreter {
public void accept(String[] parameters);
}
class TestInterpreter implements Interpreter {
public void accept(String[] parameters) {
helper.addOrder(unit, "TestInt - " + parameters[0] + " - " + parameters[1]);
}
}
class TestInterpreter {
public void accept(String[] parameters) {
helper.addOrder(unit, "TestInt - " + parameters[0] + " - " + parameters[1]);
}
}
21.10.2020 17:05
21.10.2020 17:35
but it says getAmount() is invalid after importing Constants. It will return silver without getAmount(), but doesn't work with getAmount().You must import magellan.library.gamebinding.EresseaConstants, of course.
I do not so I will shift gears into "programming to an interface"If you don't know what "programming to an interface" means, you should probably look into that before caring about lambda expressions.
22.10.2020 00:22
23.10.2020 04:05
Sounds like a good idea!By the way if you want to hang out at the Eressea Discord server, you could connect to some other Magellan users.
Map DICTfunctions = new HashMap();
DICTfunctions.put("initialization", new initialization());
interface Interpreter {
public void first();
// XXXXXXXXX public void second(Region region);
public void run(Unit unit, List args);
}
public class initialization implements Interpreter {
public void first() {
// Do stuff here
// XXXXXXXXX int[] VARdata = DICTfunctions.get("initialization").second(region); // unsure of this
int[] VARdata = second(region);
// Do more stuff here
}
// XXXXXXXXX public void second(Region region) {
public int[] second(Region region) {
int[] VARdata = new int[6];
// add data to VARdata
return VARdata;
}
}
26.10.2020 00:04
26.10.2020 04:01
I just have any (1) unit that runs the entire script. This unit gets a message "; Runs Extended Commands Script" every turn so I don't forget which one it is There won't be any other units with individual commands. This may not be what was intended with Extended Commands, but when I am gathering information for each region I also loop through each units orders with getCompleteOrders(). I have commands similar to Template/Vorlage that are then read and stored in a List until I am ready to run all orders. While looping through the orders I grab anything with // and put them back in the units new orders so they are always there. I just prefer to be able to see the commands of every unit right in the orders instead of another window and this allows me to choose the order in which they are executed. I am also able to grab the default LONG order and store it in a Map should I need to grab it later which I only currently do for the ROUTE command during this loop.Who is calling your first()?
I have added multiple things to the Interpreter interface and have them working good (at least to the best of my knowledge). I still have a ton to learn on this subject as I haven't read a ton on the "Programming to an Interface", but I have done a fair amount of reading on it since you mentioned it to me.Does it make sense to add it to the Interpreter interface?
As mentioned above, I accomplish this when looping through the unit orders before they are removed. I do the same thing to determine any help silver sent/received, previous turn earnings/costs, etc... looping though unit/faction messages.There is no way to get the default orders back.
26.10.2020 14:42
26.10.2020 23:49
I have had a lot of moments LoL! I have seen that Execute button in the Extended Commands window since I started this project.Solthar hat geschrieben:This is similar to what I am doing.
You can run an individual unit's script either with the Execute button in the editor or by right clicking it in the overview tree and selecting ExtCmds->run script (or something).
import magellan.library.gamebinding.MovementEvaluator;
addMessage(unit, "" + MovementEvaluator.getWeight(unit));
addMessage(unit, "" + MovementEvaluator.getPayloadOnFoot(unit));
addMessage(unit, "" + MovementEvaluator.getPayloadOnHorse(unit));
import magellan.library.gamebinding.MovementEvaluator;
int lbs1 = MovementEvaluator.getPayloadOnFoot(unit);
int lbs2 = MovementEvaluator.getPayloadOnHorse(unit);
28.10.2020 02:24
28.10.2020 04:25
MovementEvaluator MoveEval = world.getRules().getGameSpecificStuff().getMovementEvaluator();
I had this happen before and when I paste my code into a different editor I can see a unknow character. Deleted it and it works now. I think this happens when I copy and paste code for some reason.The \u200b error is weird (google it). Looks like you somehow got a weird character into your code.
28.10.2020 11:28
28.10.2020 17:30
That is what I was guessing, hopefully I won't scare you away with a ton more questions!I think you really would want to create an actual plugin
Done! I am assuming I just wanted the Eclipse IDE for Java Developers version.Get Eclipse, get the magellan sources and the plugins
You say that now Remember, I have no REAL experience doing any kind of coding, especially Java! I just play with code till I can make some sense of it as I enjoy learning it. I am sure my code is extremely "dirty"!It's a bit of a learning curve, but much more fun.
Just in case I explained that wrong...my script for Extended Commands would still be in the Library. Basically, I just want a button in my plugin that would tell Extended Commands to Execute the Library. If its still not recommended I will skip that idea.Executing your scripts from within a script ... I will not say it is impossible, but I wouldn't recommend it.
31.10.2020 10:11
01.11.2020 18:33
I had tried both ways. First tried the whole addon package and then each addon individually. I receive the following error:I think the best way is to import not the magellan2-extensions-plugins project, but every plugin as its own java project. For example MemoryWatchPlugin or YourPlugin. Then you have to tell the plugin project where to find the Magellan sources, by going to the project properties -> Java Build Path -> Projects and adding the Magellan2 project there. When I have time, I will try to go through the process myself and describe it in more detail. For now, you should be fine with the plugin in the Magellan project itself.
I used git a little before, but need to better familiarize myself with it when I have time.As a note: I strongly recommend to use git to manage and archive your own progress while developing. Maybe more on that later.
I started with using the teacher plugin as my template. I have been adding and deleting code to better understand. I have successfully created my GUI (JPanel) with some information on it to test. I somehow figured out how to send my JComboBox (Region) to the client fairly quickly to my surprise. It took me much, much longer to send the client Active Region to my JComboBox. I actually spent way too much time to get the "client" info. I think I pretty much found it by mistake! Once I discovered that Magellan plugins calls init() which allows me to get the client I made progress. The teacher plugin base I am using didn't send client to the GUI so I was able to change that and then finally was able to send the active region to my JComboBox I tried going off the getSelectionType() without success as it was always returning 0. I am not sure if this is the best way, but I ended up using the following code:For adding a listener you have to implement the magellan.client.event.SelectionListener interface
public void selectionChanged(SelectionEvent se) {
Region region = (Region) rBox.getSelectedItem();
if (!data.getActiveRegion().equals(region)) {
region = data.getActiveRegion();
rBox.setSelectedItem(region);
setActiveRegion(region);
}
}
This was VERY VERY helpful You have no idea how much easier this whole project has been with your guidance. It is making this process VERY enjoyable! My profession is in Sales and Management and I just play with coding when I have time as I really enjoy it. I don't know any languages really. Just pieces and parts of languages from wanting to do a certain project (mostly to do with games ) I understand a descent amount on Java coding now as I never tried Java until this project, but proper layout(still want to do 1 long script instead of multiple classes, methods, etc.) I still have a long way to go.* by selecting SelectionListener, for example in the editor and calling the Type Hierarchy by pressing F4 you can see all the classes that implement SelectionListener.