Author Topic: Adding Health and Velocity w/ code?  (Read 3279 times)

Hey, I'm developing an addon and I don't want to type
exec("add-ons/blah_blah/toilet.cs");
It would be cool to do something like
quickexec("toilet.cs");
It could execute anything in the blah_blah file.
I'm not shure how I would go about this. Preferably it would be nice if I could do this serversidedly or clientsidedly. I guess, if I get one for client side, I don't need one server sided.
« Last Edit: September 14, 2013, 11:53:45 PM by Johnny Blockhead »

%p = "add-ons/blah_blah/*.cs";
for(%f=findFirstFile(%p);strLen(%f);%f=findNextFile(%p))
    exec(%f);

%p is the pattern
%f is the file name
findFirstFile finds the first file with that pattern
strLen(%f) is to check if there is a string ther (will return 0 for "")
findNextFile(%p) finds the next file with the pattern

that would be, client sided, yes?

that would be, client sided, yes?
both, if you run it on the server it's server sided.
Run it on the client and it's client sided.

both, if you run it on the server it's server sided.
Run it on the client and it's client sided.

amazings

just pointing it out

if your using this for development, meaning your making small changes without relaunching blockland

you can just hit the up arrow and it will fill in with whatever you typed last

Um, I just use e(Prefix_Name);

That should work, plus it's quick to type. It auto-executes server.cs, so you'd have to make that, and put exec("./toilet.cs"); in it.

Um, I just use e(Prefix_Name);

That should work, plus it's quick to type. It auto-executes server.cs, so you'd have to make that, and put exec("./toilet.cs"); in it.
Gotta give you props especially since I kinda slighted you twice. I don't know why, but few people know about e[/. It's a shortcut for exec that accepts partial pattern matching.

Um, I just use e(Prefix_Name);

That should work, plus it's quick to type. It auto-executes server.cs, so you'd have to make that, and put exec("./toilet.cs"); in it.

You wouldn't have to specify the folder?

You wouldn't have to specify the folder?
All you have to do is type e(Prefix_Name);, where Prefix is the first part of the addon name (i.e. Player), and where Name is the rest of the name after the prefix. As long as you have a server.cs in that addon's folder, it will work (executing the server.cs).

New Question:

How would you add relative velocity and health with the methods of code.

By health I mean one for maximum health, the other for healing (not going outside maximum health)

New Question:

How would you add relative velocity and health with the methods of code.

By health I mean one for maximum health, the other for healing (not going outside maximum health)

playerObject.dump();

playerObject.dump();

Typed that into console, could not call the function 'dump'

Max health is fixed by the datablock. This can be worked around by setting a really high max health and modifying it on spawn.

To set the player's current health state (i.e. heal them), you can use %player.setDamageLevel(%damageLevel);. Keep in mind that with the damage level, 0 means no damage has been done. Basically, it is the inverse of the player's current health, or how much damage they have taken. To "set" the max health, you can kill them off once they reach a preset damage level. Otherwise, they'll die when they reach your super high max health level.

For velocity, use applyImpulse(%player.position, "x y z");. Not sure if that's relative or not; if not, you'll need to figure out how to convert world rotation to local rotation.

Thanks for the help, I just need to know one more thing.

How would you store things to a client? Example: In gamefandan's server, you can do /saveme to save stats, and /loadme to load them, even if you reconnect. To my knowledge, he stores them by name. I think, if possible, it would be more efficient to save by bl_id. If you do %level = "2"; and some more code with that, it will make it so every time some one levels up, everyone else's levels would be set to that. How would you make it individual?

Also, for the relative velocity, I will look into the event mod for it.