theY4Kman / pysmx

Python package to interact with SourceMod plug-ins
https://pypi.org/project/pysmx
19 stars 3 forks source link

ConVar support #4

Open jaredballou opened 8 years ago

jaredballou commented 8 years ago

Hi, I added a very crude attempt to put CreateConVar and GetConVar(Bool|Int|String) support into my PySMX fork with little success. It seems like an essential part of making any plugin work, and I'd love to help add this to PySMX. If you look at my fork you can see what I've done, but it's far from functional at this point. If there is anything I can do to help make this work, let me know.

theY4Kman commented 8 years ago

I had a go at this last week. I had success, but eventually became disappointed with the convoluted state of the package and called it a night. I'll commit this soon, as I also try to bring the package toward a maintainable state.

btw, you might want to use an editor that displays whitespace, particularly the difference between tabs and spaces, like this: Show whitespace I noticed a place in your code where tabs and spaces are mixed. Because the size of a tab width can be different between editors (some use 8 spaces to a tab), it's easy to mistake indentation levels.

theY4Kman commented 8 years ago

I committed a proof of concept in 9b6920a6be439dd87b343426ffc71f2f7590e8f8. String stuff got a bit hairy, so it's not in there for now.

jaredballou commented 8 years ago

Yeah I hate the fact that python uses spaces instead of tabs. But I pulled your latest code to my fork, I am going to see if I can't learn from what you did and add the get/set functions for all the other types.

Whats your thinking around commands? I need to support Reg(Console|Server|Admin)Cmd functions. My plan was to just stub them, but were you planning on supporting any kind of command interface for the runtime?

theY4Kman commented 8 years ago

Yes, the plan is to simulate or at least stub the most used of the SM natives. You'll be able to extract info about convars and commands through an exposed interface.

btw, Python doesn't care whether you use tabs or spaces, as long as it's consistent. As a pragmatist, though, I prefer spaces, because it simply avoids trouble.

jaredballou commented 8 years ago

Cool. I posted in the other issue regarding some stubs I threw in, and some ideas on how to read the .inc files and generate the stubs for us. My guess is that doing all the natives by hand will quickly get monotonous and boring, so finding a way to use some automation might make it easier. I'll wait on making any serious changes for a bit, I see you pushed another commit last night and I really need to sit down and read through all the code to start understanding it better. I'm really excited about the potential to unit test my SourceMod plugins, especially given how bad I am at writing efficient Pawn code.