Vorab: Ich weiß nicht ob es so einen Thread schon gibt, falls doch, bitte löschen.
Important: Falls Ihr *.py Dateien aus dem Metin2 Client verwendet solltet ihr aufjedenfall Python 2.2 installieren und verwenden!
Hallo Community,
ich dachte mir ich zeige euch heute mal wie Ihr eure Python Scripts kompilieren könnt. (In unserem Fall einfach mal eine *.py Datei in eurem Metin2 Client)
Für das Tutorial benötigt Ihr folgendes:
Python (ich verwende Python 3.3.1)
Einzelne *.py Scripts
Zum Tutorial:
Ihr installiert euch wie oben erwähnt Python, geht in den Pfad indem Ihr es installiert habt und legt am besten einen neuen Ordner an. (z.B 'my_own_scripts')
Dort legt Ihr nun alle *.py Dateien rein, die Ihr kompiliert haben wollt.
Nun geht Ihr zurück in das (in meinem Falle) Python33 Verzeichnis und startet von dort aus die 'Python.exe'.
Nun öffnet sich eine Konsole, in der Ihr folgendes eintragt:
Code:
Falls Ihr compileall verwenden wollt:
import compileall
Falls Ihr py_compile verwenden wollt:
import py_compile
Erklärung:
Dieser Befehl importiert 'compileall.py' oder 'py_compile' und ermöglicht es uns Befehle aus diesem Script zu verwenden.
Danach kommt dieser Befehl:
Code:
Falls Ihr compileall verwenden wollt:
compileall.compile_dir('my_own_scripts', force=True)
Falls Ihr py_compile verwenden wollt:
py_compile.compile("my_own_scripts\dateiname.py")
Erklärung:
COMPILEALL: Dieser Befehl listet alle *.py Dateien im Ordner 'my_own_scripts' im Python33 Verzeichnis auf und kompiliert Sie im Pfad: 'my_own_scripts\__pycache__\'.
PY_COMPILE: Dieser Befehl kompiliert eine einzelne *.py Datei im ausgewählten Verzeichnis.
Falls Ihr dass erledigt habt wird in eurem Ordner 'my_own_scripts' ein neuer Ordner namens '__pycache__' angelegt, indem sich nun die kompilierten nicht mehr *.py sondern *.pyc (Python Compiled) Dateien befinden, diese können falls Ihr Python 2.2 verwendet habt, normal in eurem Client weiterverwendet werden und halten zumindest Kinder von dem Inhalt eurer Python Scripts ab.
Du weißt schon wenn du das mit Py 3.3 Kompilierst,dass Metin2 das nicht lesen kann weil Py 2.2 das anders kompiliert? Außerdem würde ich py_compile benutzen. Ich kann keinen Zusammenhang zu Metin2 hier erkennen.
Metin2 uses python2.2.1, u cannot import a pyc module compiled in other python version (only with python2.2.*, python2.2.2/2.2.3 allowed)
Every .py, when imported, generates the relative .pyc (or .pyo if u start python.exe with -O option) in byte-code and runned.
Therefore, in agreement with the above points, u can create a relative pyc/pyo file simply importing them
Without a program of dubious origin:
Download python2.2 (official website)
Start python.exe (with -O option if u want a pyo file instead of a pyc, -O=optimization) and:
Code:
#first way A (compile and import XXX.py file)
try:
import yourmodule #create a .pyc/o file from .py if .pyc/o file not exists
except ImportError:
pass
#first way B (compile and import XXX.py file)
import __builtin__
try:
__builtin.__import__("yourmodule") #create a .pyc/o file from .py if .pyc/o file not exists
except ImportError:
pass
#second way (all recursive py files in XXX directory and subdirectories)
import compileall
compileall.compile_dir("lib/", force=1) #in python2.2 bool not exists, metin uses TRUE and FALSE constants with the relative values 1 and 0, in python u can use a / instead of \ to indicate paths
#third way (compile XXX file)
import py_compile
py_compile.compile("yourmodule.py")
Now, to load in client (ymir has rewritten __import__ function) ur pyc file u must use marshal module like this:
Du weißt schon wenn du das mit Py 3.3 Kompilierst,dass Metin2 das nicht lesen kann weil Py 2.2 das anders kompiliert? Außerdem würde ich py_compile benutzen. Ich kann keinen Zusammenhang zu Metin2 hier erkennen.
Mein Hasi, in deinem satz steht schon die Lösung Nachdenken----Komplieren = Lösung <3
B2T: Schöne sache, jedoch gibt es da noch paar haaken.
[LazyRelease] Log python npc scripts from TQ! 07/12/2014 - CO2 PServer Guides & Releases - 43 Replies Ok so I posted about this ages ago but realized after being msg'd on youtube that I've never actually posted the code to do this...
As many of you know, I never bothered adding npc scripts for well... any npcs in the hellmouth source...
THIS WILL ONLY LOG NPC SPAWN LOCATIONS AND THE FIRST PAGE OF TEXT/OPTIONS WHEN YOU TALK TO THEM!!!
I've also been trying to encourage people to use the damn external python scripts but so far they haven't taken much of an interest... well here's...
[SERVICE]Python-Scripts Erstellen :) 02/17/2012 - Metin2 Trading - 0 Replies Heyho,
In diesem Thread bitte ich meine Python kenntnisse für euch an ^^
Ich erfülle alle wünsche (soweit wie möglich)
Kleinere Scripts mache ich auch Kostenlos :)
Der Preisvariert je nachdem wie lange es dauert und wie umfangreich das scripts sein soll.
Beispiele:
Automaton Scripts python 12/17/2010 - Flyff Private Server - 1 Replies hi Leute hi ********
ich war schon lange nicht mehr on und nun habe ich wieder lust und zeit Fame zu spielen
ich suche wieder scripts in python geschrieben für automaton 1.3
pls hab schon SuFu und gegooglet leider nichts gefunden weis auch nimmer wie die scripts heisen.
PM me oder post
PYTHON SCRIPTS AUSFÜHREN 03/12/2010 - Metin2 - 2 Replies kennt jmd in metin2 n py script, das ein anderes script ausführt, oder weiß jmd wie man das macht??