The online racing simulator
I have uploaded the binary distributable for 0.1.3 to the first post. If you are a Windows user can just download that and run the exe, which will install it automatically.
-
(Nadeo4441) DELETED by Nadeo4441
i have installed 0.1.3, and im getting same error..
There could be an issue with the Pyinsim installation, which can happen if you're upgrading from 0.1.2 (but won't happen for future upgrades as the bug has been fixed in 0.1.3).

Go to X:\Path\To\Python\Lib\site-packages and delete the following files:

Pyinsim.py
Pyinsim.pyc
Pyinsim.pyo

There should also be a folder called Pyinsim, but don't delete that, as that's where 0.1.3 has been installed. Now the script should work...
i removed Pyinsim folder, and that 3 files . After that i have installed 0.1.3 . I got this :
ImportError: No module named Pyinsim

After that i copied the files from Lib\site-packages\Pyinsim
to Lib\site-packages\ ... and it worked
Thanks for your help anyway
I said not to remove the Pyinsim folder, but I could have been more clear, sorry.

As I said this was a bug in 0.1.2 which has been fixed now, so it won't happen again for future upgrades.
Oh, sorry, im blind :shhh:
Sorry for doublepost, im testing this, and im stucked in that sittuation :

def Msg(mso):
msgt = mso["Msg"]
if msgt == "eTS.NadeoSvK : ^L!test":
SendMessage("/msg " + msgt)

if i type !test, it starts posting msgt ,and dont stop

// i know , its normal, but how to fix it?
Quote from Nadeo4441 :how to fix it?

Quote from InSim.txt :struct IS_MSO // MSg Out - system messages and user messages
...
byte UCID; // connection's unique id (0 = host)

if mso["UCID"] != 0 and msgt == "eTS.NadeoSvK : ^L!test":

if mso["UCID"] != 0 [B]and[/B] msgt == "eTS.NadeoSvK : ^L!test":

There's no && in Python.
thanks guys

//Edit: DarkTimes: What about an OutSim&OutGauge support?
I have uploaded 0.1.4 to the first post, which contains a few tweaks and additions.

Changes:

- You now define the default values for packets with traditional-style parameters, instead of passing a dictionary. Sadly this is a breaking change (the first one!), but the code looks much nicer like this.
isi = Packet(ISP_ISI, ReqI=1, Admin="FishDance", IName="Pyinsim")

- The prefix char in IS_ISI is now an actual char instead of a byte, so you don't need to cast the prefix char into a byte yourself. Yes, I know, but it wasn't as simple to add as it sounds.
isi["Prefix"] = "!" # This works now!

- Multiple packets obejcts can now be sent with a single SendP() call. The packets will be sent one after the other, in the order they are specified. For example:
insim.sendP(isi, tiny, mst)

- An interesting little idea I had was to use XML to create packets, so I've added a new function called packetXml which will return a packet object created from XML data. You can either parse XML from a file or from a string. Here is an example:

The XML file, called Packets.xml. You define a Packet element and give it a Name attribute, which is important as you will use that to reference the Packet later on. The rest of the info follows the typical InSim packet stuff. Anything you omit from a packet will be filled in with appropriate default data before it's sent (which is the same for everything in Pyinsim really).

<?xml version="1.0" encoding="utf-8"?>
<Pyinsim>
<Packet Name="Init">
<ReqI>1</ReqI>
<UDPPort>0</UDPPort>
<Admin>Pass</Admin>
<IName>Pyinsim</IName>
<Prefix>$</Prefix>
</Packet>
<Packet Name="HelloMsg">
<Msg>Hello, world!</Msg>
</Packet>
</Pyinsim>

You call PacketXml() and pass in the type of packet you want to create, the Name attribute for the packet in the XML file, and also the path to the XML file. PacketXml then parses the data and returns a regular Packet object populated from the XML.


xmlFile = "Packets.xml"

isi = packetXml(ISP_ISI, "Init", xmlFile)
mst = packetXml(ISP_MST, "HelloMsg", xmlFile)

insim.sendP(isi, mst)

Anyway...
Quote from Nadeo4441 ://Edit: DarkTimes: What about an OutSim&OutGauge support?

Yes, I'm going to add that soon. I'm just trying get the InSim part right first.
if im a windows user , how to install it ? (0.1.4)
Run the installer?
doesnt work...
If you don't describe the problem, we can't help you. If you have Python installed, there should be no problems at all.
i have python installed , and i have Pyinsim 0.1.3. I click on the setup.py , it shows something but closes ... and it doesnt work..
Edit: I have now uploaded a new fixed installer to the first post.
oh , i got it now, thanks
Due to a request I have created an example of how you might go about using commands like "!help" and "!admin".

from pyinsim import *
insim = InSim()

def messageReceived(insim, mso):
command = parseCommand(mso, '!')
if command[0] == "help":
print 'Help command'
elif command[0] == "admin":
print 'Admin command'
elif command[0] == "report":
print 'Report', command[1]

insim.Bind(ISP_MSO, MessageReceived)

try:
insim.connect("127.0.0.1", 29999)
except Exception, (msg):
print "Error:", msg
else:
insim.send(ISP_ISI, Admin="Pass", IName="Pyinsim")
insim.run()
finally:
insim.close()

I've been playing LFS for a couple months and wanted to get started in some InSim programming. Thanks very much for this Python module, it made my day.
-
(DarkTimes) DELETED by DarkTimes
Thanks! Glad you find it useful.
I'm fiddling round to get the button example from the thread's first page to work, but my button still only appears in singleplayer mode.
I changed the UCID to the actual player's one - didn't really help. Hints?

InSim.SendP(self, Packet(ISP_BTN, ReqI=1, ClickID=0, UCID=ucid,
BStyle=ISB_DARK, W=40, H=10, T=30, L=5, Text=speed))

It's been a while since I did any work with InSim, but I think it's because of the ISF_LOCAL flag on this line:

insim.SendP(Packet(ISP_ISI, Admin="Pass", IName="Pyinsim", Flags=ISF_LOCAL))

This flag, I believe, tells InSim to only display buttons in single-player mode, or if you are a guest on a server (not the host). Change the line to:

insim.SendP(Packet(ISP_ISI, Admin="Pass", IName="Pyinsim"))

and it should work in multiplayer.

As I say, been a while, but this should work. I reckon this is the fundamental root of the issue.
Yep, the ISF_LOCAL flag was the problem. Thanks!

FGED GREDG RDFGDR GSFDG