Page 1 of 1

Import error player.wapons

Posted: Wed Sep 18, 2013 12:40 pm
by mister-man
Hay,

I tried to import player.weapon and it seems there is an error.

Code: Select all

from players.weapons import get_ammo


Code: Select all

[SP]  Caught an Exception:
Traceback (most recent call last):
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
48, in __missing__
    instance = _LoadedAddon(addon_name)
  File '..\addons\source-python\packages\source-python\addons\manager.py', line
237, in __init__
    self._addon = __import__(addon_name + '.' + addon_name)
  File '..\addons\source-python\plugins\realisticAmmo\realisticAmmo.py', line 18
, in <module>
    from players.weapons import get_ammo
  File '..\addons\source-python\packages\source-python\players\weapons.py', line
 10, in <module>
    from entities.entity import BaseEntity
  File '..\addons\source-python\packages\source-python\entities\entity.py', line
 12, in <module>
    from entities.keyvalues import KeyValues
  File '..\addons\source-python\packages\source-python\entities\keyvalues.py', l
ine 12, in <module>
    from paths import DATA_PATH

ImportError: cannot import name DATA_PATH

Posted: Wed Sep 18, 2013 2:44 pm
by Ayuto
Update your installation. I fixed that 4 days ago. :)

Posted: Wed Sep 18, 2013 2:55 pm
by satoon101
As Ayuto states, the name change was fixed already. Though, I am not sure why you are trying to import a method which is already included in PlayerEntity. You cannot import a method, anyway, only global objects in a module. If you wish to use get_ammo, just use it as it is designed:

Code: Select all

from players.entity import PlayerEntity

player = PlayerEntity(<index>)
ammo = player.get_ammo('m4a1')

# You can also use the full entity name
ammo = player.get_ammo('weapon_m4a1')
Satoon

Posted: Wed Sep 18, 2013 3:50 pm
by mister-man
Okay thanks... my mistake ;)

My first try to do something with weapons!

Posted: Wed Sep 18, 2013 4:03 pm
by satoon101
Sorry, forgot to mention, but the data for the property values needs to be updated. I keep forgetting to do that, so I will do that right now.

Satoon