Sizable Scripting

Share your guides, how-tos, FAQs, and so forth. This is not for support -- post questions in General Discussion.
Post Reply
User avatar
Gargl Kark
Posts: 484

Sizable Scripting

Post by Gargl Kark »

Hi,

The issue
there is, as known, a steady discussion about this server being corrupted by players/staff/reptiloids/youNameIt. I disagree.
It's quite obvious though that only a small fraction of gameplay is used, simply because all the world is using the same scripts. The most prominent example is MB's heartwood script. This inflicts gameplay heavily: archery/carpentry based templates profit, while other runics are not so abundant. I don't care so much about the gold and market, but it's clear that template variety is discouraged by this.
MB's script, while quite brilliant, is a negative example on how to code (sorry mate - I'm not the praising type): trying to alter it will take days.

The idea
Let's try and guide people, so they can develop their own ideas :)

So instead of just sitting there and complaining, I'd rather suggest to enable people to craft their own scripts, and make them more understandable, sizable, deployable.

This is in the hope that we will, for some time, get new ideas on how to do things. We will see what comes out of this.
Of course everybody can read, research and educate themselves. But why leave them alone? Some will have great ideas but will not implement them, because they do not have the time. Others will try to use scripts but fail, or want to make them better but cannot do so.
Hence: if we simplify the way scripts are written, we make more and better options on how to interact, how to play.
In the sense of Open Source development: sharing is caring.

I'll just start now - join if you like!


Basics
explain
  • make a header section that explains what the script does. keep that short
  • also, explain what known issues are in it. mark open spots with TODO
  • if possible: enter a version number
example:

Code: Select all

////////////////////////////////////
//   This macro is designed for   //
// training alchemy from 30. Have //
//  5 empty kegs on you and a lot //
//  of mortars and pestals. This  //
//   macro only makes PVP worthy  //
//   potions to minimize waste.   //
//                                //
//  Turn on loop and click play!  //
//                                //
//      ~~Made by kdivers~~       //
////////////////////////////////////
contact
  • who are you? how can we contact you in case we have questions?
example:

Code: Select all

// made by MB: https://www.uogdemise.com/community/memberlist.php?mode=viewprofile&u=59
naming
  • use readable, self-explaining names for variables
  • make them lengthy, to minimize the likelihood to collide with other scripts
  • follow a naming pattern with all names, like place/purpose/effect
  • utilize the most common language in use (here: english)
example:

Code: Select all

if not @findobject 'HeartwoodTailorQuestGiver'
  promptalias 'HeartwoodTailorQuestGiver'
endif
nesting
  • cut your script in small, readable units
  • begin each unit with a comment that explains what it does
  • each unit should be able to stand for itself, so it can be cut and tested/re-used by itself
example:

Code: Select all

//make sure there are always 2 sewing kits
while counttype 0xf9d 'any' 'backpack' < 2
  usetype 0x1eb8 'any' 'backpack'
  waitforgump 0x38920abd 15000
  replygump 0x38920abd 8
  waitforgump 0x38920abd 15000
  replygump 0x38920abd 44
  waitforgump 0x38920abd 15000
endwhile
deploying
  • be very strict about using serials! if you need them, use promptalias
  • make it very clear what prerequisites are required and list them in a comment section
  • find a public place where to maintain your script. provide links to it
example:

Code: Select all

//1. Character needs Fletching, Carpentry and Tinkering, a Fletching Bonus talisman saves resources
//2. FletcherDropoff container needs bolts, ingots, boards in it
//3. FletcherRunebook needs 1st rune to be Dropoff location and 2nd rune near Heartwood entrance
//4. Start in Heartwood with a beetle full of only boards. Have crafted tinker tools, 40 ingots, and 200 bolts in your pack or start at your Dropoff location to restock these items
//5. The macro tries to feed your beetle meat every 2 hours. If you have magery it will create the food for you.
//6. If multiple stacks of boards at your dropoff, script will begin encountering errors when one of the stacks drop below 1600, combine them before this happens
Advanced
debugging
  • write feedback to the journal f.e. by using msg command
  • try breaking the script by doing stupid things while running it; write down what happens
  • make it robust by finding counter measures against those things
  • avoid player interaction! (in the sense of "don't make me think", if you want to enforce player interaction that's fine)
Disclaimer:
All of this may seem as if I know about coding. I don't. But I know when I can read and use code and when not.
:)
Whammy | Timezone: GMT+2

2020-09-17: SALE | Jewels List
User avatar
The Silvertiger
Posts: 4469

Re: Sizable Scripting

Post by The Silvertiger »

Love the idea. The biggest issues I see as someone who has been assisting people with scripts even though I'm basically intermediate is lack of reading errors in journals, lack of reading "deploying" directions, lack of knowing what variables that are available, and too many if's. The number one thing is reading.

I wholeheartedly agree that prompts are better than sets for beginners. That's why with the training profile that I've been developing over the last few years, I always use prompts.






Rips MB then uses his script for almost all of the examples....
:stick:

Also, in reply to your runic topic. The reasoning is very simple: I can get one 4 mod runic that is basically a 5 with wood bonuses far easier than I can get the same 4 using other methods. For example, I want a 4 mod runic to burn weapons. I spend one day turning in quests and I obtain a saw or kit or I spend one day collecting 621 bods, sort those into resets and trash, fill resets, turn in resets, hope I got enough for at least a gold (3-4) all of the same material, amount and quality, and finally I have to fill those bods and turn them in. Which would you rather do based on effort? Oh I forgot to add collecting materials for each example. I go buy bolts at a NPC and chop some trees or dig ore(or buy ingots from npc for iron) and most of what I get I don't even need most. I would say the way of the smith is more fun, but the ease of the carpenter makes Jesus into God.
Never forget June 4th 1989!
Selling List & Vendor

"Screenshots will never be used as evidence but more of a reference tool for us to help in our investigations."
Gargl Kark likes this.
Top
User avatar
Gargl Kark
Posts: 484

Re: Sizable Scripting

Post by Gargl Kark »

The Silvertiger wrote: September 12th, 2020, 7:18 pm
  • lack of reading errors in journals
    couldn't we print out things via "msg" or such, would that help?
  • lack of reading "deploying" directions
    you mean making a nice header section? we could volunteer to fix that.
  • lack of knowing what variables that are available
    that can be fixed with faq, written in accessible language
  • too many if's.
    I agree. So what do we do against the "coding is something that must be complicated" paradigma? Because it isn't :)
  • training profile that I've been developing over the last few years
    that sounds interesting. what is this?
Whammy | Timezone: GMT+2

2020-09-17: SALE | Jewels List
User avatar
Gargl Kark
Posts: 484

Re: Sizable Scripting

Post by Gargl Kark »

The Silvertiger wrote: September 12th, 2020, 7:18 pm Rips MB then uses his script for almost all of the examples....
Yes sure I do both.
  1. PRO: The script works very well, the concept is robust and purposefull. Everybody uses it, and they succeed in doing so.
  2. CON: It's "read-only". One can almost only consume it, re-designing it is a pain. It creates dependencies for the players.
Whammy | Timezone: GMT+2

2020-09-17: SALE | Jewels List
User avatar
The Silvertiger
Posts: 4469

Re: Sizable Scripting

Post by The Silvertiger »

Gargl Kark wrote: September 12th, 2020, 9:37 pm
  • lack of reading errors in journals
    couldn't we print out things via "msg" or such, would that help?
  • lack of reading "deploying" directions
    you mean making a nice header section? we could volunteer to fix that.
  • lack of knowing what variables that are available
    that can be fixed with faq, written in accessible language
  • too many if's.
    I agree. So what do we do against the "coding is something that must be complicated" paradigma? Because it isn't :)
  • training profile that I've been developing over the last few years
    that sounds interesting. what is this?
  • I was going to mention how that mb actually does that in his script, but for someone trying to learn and play with scripts we can't put a msg in the script they are attempting to write.
  • I meant like the header in the hw script. People don't read it, then start looking for help when all they had to do was read the header.
  • The last two points are lack of reading the ReadMe in the folder.

    One of the first questions I ask is what is the journal msg, because 8/10 times that will tell you exactly what's wrong. If we can teach people to read their journals half of our problems would be solved.
Never forget June 4th 1989!
Selling List & Vendor

"Screenshots will never be used as evidence but more of a reference tool for us to help in our investigations."
Vampire337
Posts: 47
Location: Cincinnati, Ohio

Re: Sizable Scripting

Post by Vampire337 »

Programming is an instant-gratification exercise. If you *can* simply copy-paste code and see it do what you want it to, it's natural to just do that rather than learn how it's doing what it does. Also, not everyone wants to learn coding; most just want to get an advantage in game, or to simply catch up to those who already have that advantage.

Disclaimer: I'm a developer for industrial software platforms, so I do fair amount of coding. I share a lot of code snippets with colleagues who maybe aren't at my level in terms of programming proficiency, and so I write my code to be as self-documenting and decipherable as possible so I don't have to personally support other people's copy-pasting of my code.

That said, I tend to employ a lot of the strategies you describe, but UOSteam (as well as Razor; I'm not meaning to pick favorites) is a very limited development interface. UOS penalizes self-documenting by making the program harder to read if you clutter it up with extensive descriptions (you can't put // at the end of a line of code; longer lines are word-wrapped and the window is not maximizable). I intentionally omit the 'explain' and 'contact' sections to slim down the end result in my UOS window (apologies to everyone who includes those in their examples; I still appreciate you!)

Not meaning this to be a rant about the limitations of UOS tho. I'm happy to help people with their scripts. I enjoy posting reusable code snippets meant to solve a small problem, rather than fully developed programs that discourage creativity by being a one-stop-shop.
User avatar
Gargl Kark
Posts: 484

Re: Sizable Scripting

Post by Gargl Kark »

Vampire337 wrote: September 17th, 2020, 2:30 pm self-documenting and decipherable
Vampire337 wrote: September 17th, 2020, 2:30 pm UOSteam is a very limited development interface
Exactly!
Also I agree that most people would consume code rather than master it. But that's just another argument for making the code nice and readable, imo.
Whammy | Timezone: GMT+2

2020-09-17: SALE | Jewels List
User avatar
The Silvertiger
Posts: 4469

Re: Sizable Scripting

Post by The Silvertiger »

I agree uo scripting is a mostly consume and not learn environment. That's why you have to try to get them to help themselves such as asking what the error message is.
Never forget June 4th 1989!
Selling List & Vendor

"Screenshots will never be used as evidence but more of a reference tool for us to help in our investigations."
User avatar
BCrowly
Posts: 95

Re: Sizable Scripting

Post by BCrowly »

MB best uosteam scripter demise has even seen. Change my mind.
Post Reply