Lench Scripter Mod [Besiege v0.42]

Lench

Active Member
Update v2.1.0:

Lench Scripter Mod now supports both IronPython 2.7 and 3.0.
By default, the old 2.7 version will be used.

To view the current version, type
Code:
lsm python version
into console.

To switch to IronPython 3.0, type
Code:
lsm python 3.0
To switch to IronPython 2.7, type
Code:
lsm python 2.7
I recommend staying at 2.7 for now as 3.0 still has its issues.
Read about the differences between the versions here:
http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html
 
Hi Lench,
Nice that you now support botpython 2.7 and 3.0.
In both cases I have a problem importing classes.

IronPython 2.7:
sys.path.append('C:\IronPython27\Lib')
from collections.abc import ABCMeta

prints this in Besiege:

Python error: An exception was thrown by the type initializer for CodecsInfo
Traceback (most recent call last):
SystemError: CodePage 37 not supported

And python 3.0.0.0
sys.path.append('C:\Python30\Lib')
from collections.abc import ABCMeta

prints this in Besiege for every frame update:

TargetException: Object does not match target type.

I have googled yet found nothing specific. I have seen some fixes to related problems for both versions:

libmono-i18n2.0-cil

Looks like that package should be added as a dependency of the ironpython package. How do I do that?

Cheers, Simon
 

Lench

Active Member
Hi Lench,
Nice that you now support botpython 2.7 and 3.0.
In both cases I have a problem importing classes.

IronPython 2.7:
sys.path.append('C:\IronPython27\Lib')
from collections.abc import ABCMeta

prints this in Besiege:

Python error: An exception was thrown by the type initializer for CodecsInfo
Traceback (most recent call last):
SystemError: CodePage 37 not supported

And python 3.0.0.0
sys.path.append('C:\Python30\Lib')
from collections.abc import ABCMeta

prints this in Besiege for every frame update:

TargetException: Object does not match target type.

I have googled yet found nothing specific. I have seen some fixes to related problems for both versions:

libmono-i18n2.0-cil

Looks like that package should be added as a dependency of the ironpython package. How do I do that?

Cheers, Simon
You can reference CLR assemblies using

Code:
import clr          # this is imported automatically in default script scope
clr.AddReference("assemblyName")
which loads the assembly and enables you to import their namespaces in Python.

More on clr.AddReference.
 

Lench

Active Member
where can i download the libmono-i18n2.0-cil and will signing be an issue?
The name suggest this is a linux library (lib prefix and -version suffix) so I suppose with your favorite package manager. I'm afraid you're can't fix this though, it appears the libraries you're trying to import deal with native code and that simply won't work in the Python engine in Besiege.

You might be able to change the mod to start an external python process instead, which then runs the scripting engine, but I suppose that would be a considerable overhaul. I might look into that when I have time.
 
Do i have to use specifially 3.0 or 2.7 and not 3.6.1 or is that also acceptable

im going to use 3.0 for now so that I dont have to reinstall later on.

Plz reply soon
 

Lench

Active Member
Do i have to use specifially 3.0 or 2.7 and not 3.6.1 or is that also acceptable

im going to use 3.0 for now so that I dont have to reinstall later on.

Plz reply soon
The mod runs it's own IronPython engine that only runs 2.7 and 3.0 for now. You can switch between them in the game options (the screen where you change resolution) or using commands `lsm python 3.0` pr `lsm python 2.7`.

These Python engines are completely independent from the Python you have installed on your operating system. You don't have to install anything else besides the mod, and they're inaccessible from outside the game.
 
I don't know if it's just me or is this system hard but I happen to not know where you write the scripts. I bet it's just me being retarded, but there's no clear file saying something like "Script" or something like that. I tried opening the file called Python but it shows me a black control screen and it makes me confused because I think it should be white or gray or something.
 
For now, I'm still doing Scratch (Cause I suck) and I did try JavaE++ or something like that once but I gave up after my old computer got fried. I hope that I understand Python soon.
 

Lench

Active Member
I don't know if it's just me or is this system hard but I happen to not know where you write the scripts. I bet it's just me being retarded, but there's no clear file saying something like "Script" or something like that. I tried opening the file called Python but it shows me a black control screen and it makes me confused because I think it should be white or gray or something.
That happens because the .py files are associated with the Python engine, so when you double click them, they are executed. Instead you should try opening them with notepad or some other text editor.

And if you're completely new to python, I suggest going through https://www.codecademy.com/learn/python.
 
That happens because the .py files are associated with the Python engine, so when you double click them, they are executed. Instead you should try opening them with notepad or some other text editor.

And if you're completely new to python, I suggest going through https://www.codecademy.com/learn/python.
OMG I tried out the website and I got instantly hooked. Thx for the link!

Btw is there a way I can see the source code (Idk what that means, but I'll refer it to as the python code) of the sam and agm missiles? I've been frying my brain thinking about how the code could be like and I couldn't figure it out. Thx!
 

Lench

Active Member
OMG I tried out the website and I got instantly hooked. Thx for the link!

Btw is there a way I can see the source code (Idk what that means, but I'll refer it to as the python code) of the sam and agm missiles? I've been frying my brain thinking about how the code could be like and I couldn't figure it out. Thx!
Yes. You can open the script options window (the cog button) and press export. This will save the current machine's script to a .py file.

For the SAM machine, you can just look here:
https://pastebin.com/TA9FsUHE
It's pretty advanced though and you'll need some serious math to fully understand it.
 

Lench

Active Member
I can tell already that it's complicated. How long did it take you to write it?
I think about a week to figure it out, write it and tune it. But I had a lot of knowledge about PID controllers beforehand.

If you're interested, I suggest you work your way through my guides here: https://github.com/lench4991/LenchScripterMod/wiki/Getting-started
Just following the code will get you to a quad drone autopilot.

Also, you're welcome to join us on Besiege Discord server, where I would be happy to help you with questions.
https://discord.gg/33WPYEP
 
I think about a week to figure it out, write it and tune it. But I had a lot of knowledge about PID controllers beforehand.

If you're interested, I suggest you work your way through my guides here: https://github.com/lench4991/LenchScripterMod/wiki/Getting-started
Just following the code will get you to a quad drone autopilot.

Also, you're welcome to join us on Besiege Discord server, where I would be happy to help you with questions.
https://discord.gg/33WPYEP
Interesting... Actually, at school now, math is one of my strong sides, but I still couldn't figure out how the algorithm works... I'll see about the discord.
 
Hey Lench I was following the tuorial for the first car thing and I did everything the way it is on the page except for different GUIDs but nothing works I check watchlist and it doesnt work too. why does this happen?
 
I tried reinstalling python and is it because Im using the 64 bit version for the 3.0 or something else? Sorry if im being annoying but im frustrated with myself because I cant get it to work. U should probably have noticed that by the way my typing gradually gets worse because Im so frustrated soz
 

Lench

Active Member
I tried reinstalling python and is it because Im using the 64 bit version for the 3.0 or something else? Sorry if im being annoying but im frustrated with myself because I cant get it to work. U should probably have noticed that by the way my typing gradually gets worse because Im so frustrated soz
You should really join me in that Discord chat, it's hard to help you through these forum posts.

And you don't have to install anything.
 
Top