Author Topic: Educational Scripts & Trivia  (Read 2371 times)

Hello! I think I did this on the RTB forums a while back. Anyways, I'm releasing some code I've hoarded since early 2009, with some changes. For educational purposes only. For once, that's pretty much genuine. If you run any of this, I probably wouldn't want to be around you. Most of these are official crap-ons and will not run. Do not use these or they will forget up your Blockland.

Nearly all of these were made on v8, and zipped up to work in v9 (I think in CityRP's case I shoehorned in trigger events). Blockland's architecture has changed enough to break a good amount of these scripts, so I'll comment on them and what you may want to do to fix it.

Common Coding Mistakes
Across all the mods you can see these.
Monolithic functions with 'modes' and whatnot. Do not do this. Use as many functions as you want, and make your code readable over functionality.

No variables. Do not do this. I don't understand why I didn't use variables, but that's something I suspect made CityRP lag as much as it did, apart from the saving system. Tons of complex math done multiple times, when variables could have been used to only store the result once.

No / commands. Don't. Do. This. I blame MasterCE and Fooly Cooly for CityRP's use of ^. First of all, MasterCE decided he wanted to mod his client to send something like "/me ruins designs." in to commandToServer('me', "ruins designs."), whereas Blockland's default behaviour is commandToServer('me', 'ruins', 'designs'). The whole ^ thing is a cheap hack, as messageSent takes one argument: A full string of text. Early in the beta testing of CityRP, I had complaints to use ! instead of ^. But that'd forget up Fooly Cooly's admin panel thing. Which I didn't even use. Compatibility is awesome. Another factor was the feeling that the commands /job and /help would overwrite other mods, but yeah. Why the ^? Because nothing else really looked fancy enough, so I chose went ahead and chose possibly the worst character to type if you don't know how to touch type (I do now, eurgh).

Downloads. I've never liked having clients download files, as I programmed pre-CDN. Downloads were slow as forget, considering I lived in Australia. This is also why I neglected having a GUI system, as RTB2 didn't have the GUI downloader yet, and I detest having clients download things just for my server. I tried overriding centerPrint to put things to the right, but in the end I just used bottomPrint as it was easier.

Use version control. I didn't code with backups, as I didn't even know that there was such a thing as version control. It's infinitely better to use version control. You can revert to old versions, have different versions and just in general better. The other day I was coding something and I wasn't under version control BECAUSE IT WASN'T DONE YET HOW COULD I MESS IT UP, and I messed it up. Luckily my text editor has an enourmous undo limit.

Realize that your mod isn't why your server is good. When I released CityRP, I didn't expect things to happen like this, with millions of bad servers. CityRP was moderated and administered by Boltster and I, and we kept things moving smoothly. I didn't take this in to account when releasing it, I just automatically assumed people would moderate their servers.

No comments. Don't do that. Put comments everywhere you think you need to explain code. There's no such thing as self documenting code with the complexity we have nowadays.

Write code as if you're going to release it the next day, but don't know today. Because that's literally what happened with CityRP.

Make it work on non-dedicated servers. I didn't because garbage collection annoyed me. I screwed up.


JookGroup_JookRPG
This is pretty much the precursor to CityRP. Don't expect anything of it. It uses a similiar saving scheme, and has some neat things like aging and whatnot that I neglected to put in CityRP since it's basically a DarkRP ripoff.
The saving system stores each member's data per-line, using words. This is going to forget stuff up if you try storing spaces. Don't use it. See the Sassy section on a saving system.
The system used is pretty much monolithic like CityRP, so don't expect readable code. It uses a help system via message boxes, and all commands are prefixed with typing '/JookRPG' which kind of fixes the mod collision problem.
There's no GUI at all either.

weapon_boomBelt
I made this for Kaphonaits. It has some support code that implements requiring addons, that Badspot may have posted. I think Blockland has this built in now, though. It's probably infinitely better. It also has some code for multiple wrench modes? I don't know what that's doing there.
In general, this does a basic thing: It blows you up, and beeps.
I modeled it in Blender. Not much to be said there.

map_void
My own little slate map.

item_disguiseKit
This actually uses Space Guy's TDM mod to function. If that still exists. It's an example of a non-trivial item. It overrides a host of f

script_jookiaStuff
This was crap-onned for breaking the options menu, and not working after re-opening the game. I knew this happened, and ignored it because it wasn't actually meant to be used outside of my friends and I. An interesting project would be to use this code to make a resolution changer add-on that replaces the options menu resolution thing.
It has stuff to disable the GUI you get when playing, which is good for filming, and a chase camera that doesn't actually chase things, which I've used as a type of tripod.
It also has a camHax setting. I don't remember who told me about it being possible to do this, but it was on Aloshi's RP server. Devestator? I don't know. In v8, all it did was force the camera to move, and kept switching to it as the game switched back, meaning a clientside F8 camera. This is fixed though.

PeopleMods_CityRP
I don't think I need to explain this. Gameplay-wise at least. Codewise? This is buggy as stuff, ignoring how unprepared for v9 it was. I remember on the days before I released it, there were dead bodies that didn't get removed scattered around the server. Whatever I did to do that, I don't know.
This uses Sassy for saving, see that section to comment on the saving system.
It has RTB options, which is pretty cool.
It uses triggers for lots. Now, this can be seen as good because in the beta versions you could tell who owned the lot you were in, and some guy showed me an exploit that involved JVS Doors trust system and the onEnterLot thing to kick people out of the lot if they weren't you. It was actually pretty funny. On the otherhand, triggers suck for what CityRP does. CityRP uses triggers to determine if a brick is in a space you should be able to build in, simple math could do that. That's what CityRP2 does. In fact, Iban showed me a version of CityRPG that didn't use triggers, after I mentioned to him that CityRP2 didn't use triggers (see below).
CityRP has a saving system that parses a file containing.. Helpful information. It's coded much like Sassy, meant to be reusable. Of course, it's prone to exploits seeing as that it 'evals' the help message. Because for some reason I used the equivalent of SQL injection as a feature. I need to go work for Team Meat.
Jobs used Sassy's data function, which was useful.

Sassy
This is one of the only scripts that I'm proud of today. It's a saving system that's meant to be used for multiple mods. So far I only know that it was used in CityRP and a thing Clockturn made. There's multiple versions: One in CityRP, one in CityRP2 and the standalone one.
Sassy does support LAN, but it doesn't support people using the same ID as it means two players share the same data. A way to avoid this to use a login system, but that annoys me as stuff. When brainstorming a while back, a better solution would to have Sassy store characters and use the ID as a login itself. That way multiple players could all use different characters.
It's also very slow. It doesn't scale well. It was designed for when 10k Blockland players were unheard of. A way to avoid this would to be to use SQL. Maybe Blockland exposes the SQLite API? I don't know. I tried to use a TCP object, but I found that this would screw up as I could telnet in to the database and wreck havok by LAN.
For Ministry, I hacked a fix to speed up Sassy to not loop through every single ID using getData.

itemIcon
It's a template for item icons.
When you make a new item, you need an icon for the inventory (q menu), and for some reason the shadow background isn't already included. This is for you to put items in front of.

Gamemode_CityRP
This was my attempt at remaking CityRP, with some features that JookRPG has. It's incomplete of course, but it has aging, and triggerless lots (I'll get to that in a tick). It's also full of comments, and is modular enough that each feature is in a package.
It's very configurable (you can change the prefix thing in the message for once!) and has a simple help system that doesn't require files too.
It has a license system as well, which was something I'm sure I use to have in a RP I once made.
It also has RTB support, which I'm pretty pleased as if RTB's not there, it does nothing.
It has a new lots system. It loads lots from a Sassy data file, and generates bricks.
But with v21, I imagine this lot system helpful, conceptually if not coding..ly.. It uses 2D coordinates to find if it's okay to place a brick there. Somehow I've managed to do that in hundreds of lines of code, but that's probably because I didn't know anything about vectors when I wrote the code.

But that's about it. I feel if I get banned for posting these crap-ons, that it'd be a bit of a kick in the guts as I don't want people to use them, I just want people to learn from them. But still, there will be those who use these for evil, but even with that excuse, they could still find these on the RTB forums.

Download
« Last Edit: April 17, 2012, 07:40:10 PM by xXBeibsFan119Xx »

how in tits did you compress this down to 141 kb?

how in tits did you compress this down to 141 kb?

I didn't notice. Maybe the program I use sets the highest compression, I don't know.

Take this down. You made none of this.
Jookia made everything in OP btw.

Wait your jookia
« Last Edit: April 17, 2012, 05:35:21 PM by Brian Smithers »

they could still find these on the RTB forums.
No, actually, they couldn't. RTB forums aren't up anymore.

No, actually, they couldn't. RTB forums aren't up anymore.

That shows how in touch with forums I am.

so wait .. you're jookia .. why is your current name so handicapped ..

so wait .. you're jookia .. why is your current name so handicapped ..
OGMZ U INSULTING BEIBS!!!!

so wait .. you're jookia .. why is your current name so handicapped ..

Uh, you really shouldn't mumble, because I can't understand a word you're saying.

Back on topic. I'd like to know if this helped anybody.

so wait .. you're jookia .. why is your current name so handicapped ..
Says person whose name suggests terrorism.

Ontopic:
itemIcon
It's a template for item icons.
Some more info on that would be nice please?

Ontopic: Some more info on that would be nice please?

Updated.

Nice.
Still waiting on someone to create a brick icon generator tho.

Nice.
Still waiting on someone to create a brick icon generator tho.

Doesn't Blockland have default icon generators? serverCmdDo*.

Doesn't Blockland have default icon generators? serverCmdDo*.
I doubt it. It would be too amazing.

Doesn't Blockland have default icon generators? serverCmdDo*.
i think that's just for the letter of the name rather than actual icons of deh pictures, unless you ment by the letters