Closed Sheridan closed 4 years ago
Today i make workaround:
sheridan@eee ~/soft/Minecraft/mcc/scripts/src $ ls -1
FarmBot.cs
go-base.cs
go-gold-farm.cs
go-guard-farm.cs
go-iron-farm.cs
go-multimob-farm.cs
go-slime-farm.cs
prepare
sheridan@eee ~/soft/Minecraft/mcc/scripts/src $ cat ./FarmBot.cs
class FarmBot : ChatBot
{
private Location AFKPoint;
private string FarmName;
private string botName = "bot";
private string ownerName = "me";
private int firstSleepOnAFK = 16;
public FarmBot(string fName, Location afk)
{
AFKPoint = afk;
FarmName = fName;
}
/ /some methods and logic ...
}
sheridan@eee ~/soft/Minecraft/mcc/scripts/src $ cat ./go-slime-farm.cs
//MCCScript 1.0
MCC.LoadBot(new FarmBot
(
"Slime",
new Location(118, 6, 593)
));
//MCCScript Extensions
sheridan@eee ~/soft/Minecraft/mcc/scripts/src $ cat ./prepare
#!/bin/bash
for scrpt in go-iron-farm.cs go-gold-farm.cs go-slime-farm.cs go-multimob-farm.cs go-guard-farm.cs go-base.cs
do
cat $scrpt > ../$scrpt
cat FarmBot.cs >> ../$scrpt
done
Currently that's not possible since each script is built in a temporary namespace that is temporarily loaded so they can't easily interact with each other, this method of concatenating scripts before load seems the best way of achieving that. :)
Tell me please another thing... How i can get my bot location coordinates?... Need to add to ChatBot.cs new method?
You're right, added that :)
Ok. Thanks :)
To avoid spam, I have questions about the script will ask here is, if you do not mind ...
I made a fork of the project and intend to implement serialization of data (to json, rw) to access them from scripts, as setvar/getvar enough and it does not store a value between sessions. It will be useful for scripts settings. Where is it best to implement? ChatBot.cs?
In fact maybe allowing persistence for get/set var would be interesting?
Data for example, like such:
public struct SMob2Kill
{
public string Mob;
public int Radius;
public SMob2Kill(string mob, int radius) { Mob = mob; Radius = radius; }
}
public struct CFarm
{
private string m_farmName;
private Location m_pAFK;
private Location[] m_pCorners;
private SMob2Kill[] m_mobs2Kill;
public CFarm(string farmName, Location pAFK, Location[] pCorners = null, SMob2Kill[] mobs2Kill = null)
{
m_farmName = farmName ;
m_pAFK = pAFK ;
m_pCorners = pCorners ;
m_mobs2Kill = mobs2Kill ;
}
}
I think there is only serialization can help...
Well, indeed. You could add a json or ini file with your data and load it on bot load. (The small json utility included with MCC wasn't really designed for that)
Well, I'll try to implement it. I do not promise, however, that'll do it quickly :)Anyway, since I love scripting, I'll try to make C # scripting more convenient to be able to write complex bots without the need for edits in project code
I'm not scripting that much that's why I didn't noticed these missing features but yes, that's the purpose, previously people had to edit source code and build modified versions, that was quite tedious. Take your time :)
Tell me please, can i split my .cs script into multiple files for code reuse? E. g. implement bot in separate class and use it in my scripts with different parameters.