SRL Archive - Jr. Member General Help and Discussion

needing some help with becoming a better scripter.


chief herb

2020-05-02 03:38:01

okay so i can make some basic rsps scripts and some were complex and managed to figure a way to work it out. but now i want to make some osrs scripts and im pretty sure i need to improve my quality of script. so what all is required to have a working GOOD script now a days. and any tips/advice/ETC is greatly appreciated



so how do i go about doing so, what guides should i read, is there any videos i can watch to improve the way i go about scripting. ill continue to do some digging and reading guides cause im kinda confused but really want to learn.

THANKS <3 :sasmokin:

Element17

2020-05-03 21:37:42

Check many of the sticky guides in the OSRS Scripting section, they maybe out dated but the logic is still there.

You really just want good logic in the script and randomness. No static clicks or repeated mouse movements, etc. More human like the better but the bot detection software is pretty good now a days so its always gonna be hard.

chief herb

2020-05-07 21:47:16

From: Element17
Check many of the sticky guides in the OSRS Scripting section, they maybe out dated but the logic is still there.

You really just want good logic in the script and randomness. No static clicks or repeated mouse movements, etc. More human like the better but the bot detection software is pretty good now a days so its always gonna be hard.


how can i improve my logic, i want to learn how to make a "script state" where it knows where its at and if it doesn't equal true to the state it should be at then to get back on track. any tips or other advice mate?

Dan the man

2020-05-07 22:25:18

From: chief herb
how can i improve my logic, i want to learn how to make a "script state" where it knows where its at and if it doesn't equal true to the state it should be at then to get back on track. any tips or other advice mate?


There are a few ways to do script states, everyone handles them differently.

Depending on the activity, an example would be:
Using RSWalker to identify the location of your player, and based on that location, we set the state to do the next activity.
Here is a very basic exmaple (not using real functions) of what it might look like.
type
ScriptState = (BANK, SMELT, WALK);

function GetCurrentState:ScriptState;
begin
if (GetPlayerPos = AtFurnace) then
begin
if Ore.InInventory then
exit(SMELT)
else
exit(WALK);
end else
if (GetPlayerPos = AtBank) then
if Ore.InInventory then
exit(WALK)
else
exit(BANK);
end;

procedure MainLoop;
begin
case GetCurrentState of
BANK: DoBanking;
WALK: DoWalking;
SMELT:DoSmelting;
end;
end;
The function GetCurrentState looks at things in game to identify where our character is, what it's inventory is like, and then decides what the next task should be based on that information.
Our main loop then looks at that information and actions the function/procedure to carry out that task.

chief herb

2020-05-08 02:24:49

From: Dan the man
There are a few ways to do script states, everyone handles them differently.

Depending on the activity, an example would be:
Using RSWalker to identify the location of your player, and based on that location, we set the state to do the next activity.
Here is a very basic exmaple (not using real functions) of what it might look like.
type
ScriptState = (BANK, SMELT, WALK);

function GetCurrentState:ScriptState;
begin
if (GetPlayerPos = AtFurnace) then
begin
if Ore.InInventory then
exit(SMELT)
else
exit(WALK);
end else
if (GetPlayerPos = AtBank) then
if Ore.InInventory then
exit(WALK)
else
exit(BANK);
end;

procedure MainLoop;
begin
case GetCurrentState of
BANK: DoBanking;
WALK: DoWalking;
SMELT:DoSmelting;
end;
end;
The function GetCurrentState looks at things in game to identify where our character is, what it's inventory is like, and then decides what the next task should be based on that information.
Our main loop then looks at that information and actions the function/procedure to carry out that task.


ok is this "good logic" or are there better methods? does it depend on activity? thanks for the help <3

Dan the man

2020-05-08 04:54:59

From: chief herb
ok is this "good logic" or are there better methods? does it depend on activity? thanks for the help <3


It really depends on the activity. If you break the script down into small functions and procedures, you will have more "if this then that" to work with, allowing for a more fluid, fail safe approach.

For example, instead of having a banking function that finds the bank and withdraws/depos the items, break it into 2 functions: 1 that finds the bank and 1 that interacts with it. That way you can check the state of the character and determine if the bank is already open, allowing you to skip the whole process of finding the bank, or if the bank isn't open, start that process before interacting with the bank.

Sir R. M8gic1an

2020-05-17 03:20:29

loop until failsafe, loop until failsafe, loop until failsafe.

I think one keyword everyone can agree on for a great script is that it is reliable. These are the scripts that run for hours on end without breaking.

Most scripts walk from A to B do X and walk from B to A.

Start simple and focus on increasing the reliability of each step.

let's look at some pseudo code

procedure MineRocks
var attempts_full_inventory: int;
var attempts_find_rock: int;
var rock_found: boolean;
var rockTP: TPoint;
var rocksLostToCompetition: int;
begin
if (not LoggedIn) exit;

if (not MinningGearInInventory)
exit;


rocksLostToCompetition := 0;
attempts_full_inventory := 0;

while((InventoryFull == False) & (attempts_full_inventory < 3))
begin
if location <> MiningLocation
if (not Relocate(Mines))
begin
writeln('could not find mine')
Players.LogOut()
break;
end;

rockFound = false;
attempts_find_rock := 0;
while (rockFound == False)&(attempts_find_rock <= 3)
begin
rockFound := FindRock(rockTP);
if (rockFound ==False)
attempts_find_rock := attempts_find_rock + 1;
end;

if (RockFound)
begin
// wait for rock can include stuff like checking if its in the inventory,
// if the color of the rock is gone (mined by someone else)
// or a timer or anything else you can think of.

if not (waitForRock())
rocksLostToCompetition := rocksLostToCompetition + 1;
end;

if ((RockFound==False)or(rocksLostToCompetition >= 10))
begin
attempts_full_inventory := attempts_full_inventory + 1;
if (attempts_full_inventory < 3)
begin
RocksLostToCompetition := 0;
SwitchWorlds();
end;

end;
end;

if((InventoryFull == False) & (attempts_full_inventory >= 3) & (rocksLostToCompetiton >= 10)
begin
//assign an easier task to this player
end;

return InventoryFull;
end;

With this type of technique it's very easy to make your script more and more robust over time. Just be sure to use counters, as you don't want to end up with infinite loops !