Posts: 6
Threads: 2
Joined: Oct 2020
Reputation:
0
Hi!
I would like to request a pretty odd/special kind of script
Is it possible to make a script that does the following:
When character X1, X2, X3 (up to 10 characters) enters screen, move north like 5 sqm, and when X1, X2, X3 is off screen, move south like 10 sqm.
To clarify my purpose
Im using block chars, and need them to move when a specific character enters the screen, and move back when this specific character leave screen
Posts: 2,390
Threads: 409
Joined: Jul 2018
Reputation:
61
12-14-2020, 12:58 PM
(This post was last modified: 12-14-2020, 12:59 PM by Arkilys.)
Hello.
I see your point, but moving north 5 sqms and later, to south for 10 sqms, your character will not be back to the first place.
reachlocation() does not works when the location is out of screen, so you may need to setup multiple locations to walk after each other. As you asked to move 10 sqms to south, it will be out of your screen, so you probably need to setup two locations on script below. Add a location that's 5 sqms to south and another that's 5 sqms to south from the one you just added.
I could edit this script to use Cavebot to walk to specific locations based on wpt label.
local BLACK_LIST = { 'player 1', 'enemy guy', 'enemy maker' } -- Players to trigger.
local NORTH_LOCATION = { X = 12345, Y = 12345, Z = 5 }
local SOUTH_LOCATION = {
{ X = 12345, Y = 12345, Z = 5 },
{ X = 12345, Y = 12345, Z = 5 },
} -- reachlocation does not works when the location is out of screen, so you may need to setup multiple locations to walk after each other.
if paround(0, table.unpack(BLACK_LIST)) > 0 then
reachlocation(NORTH_LOCATION.X, NORTH_LOCATION.Y, NORTH_LOCATION.Z, true)
else
local final_south = SOUTH_LOCATION[#SOUTH_LOCATION]
if posx() ~= final_south.X or posy() ~= final_south.Y then
for _, loc in ipairs(SOUTH_LOCATION) do
reachlocation(loc.X, loc.Y, loc.Z, true)
end
end
end
Posts: 6
Threads: 2
Joined: Oct 2020
Reputation:
0
12-14-2020, 06:49 PM
(This post was last modified: 12-14-2020, 06:52 PM by JohanKampe.)
I've got a pot blocking the spot to the South
the character will walk like 5 sqm maximum to the north before it hits a wall,
and later walk 5 back before being blocked by the pot, just wanted 10 to be sure it walks all the way to the pot
Edit:
Im blocking the passage for me and a friend, and since he isnt able to move them, i want the blockchars to move to the north when his characters appear on screen, and walk back once he leaves
Posts: 2,390
Threads: 409
Joined: Jul 2018
Reputation:
61
Hello.
I see, so the script above works just fine. You have to setup 3 variables:
1. BLACK_LIST -> It's a list of players that triggers the script, which makes the script to moves to NORTH_LOCATION.
2. NORTH_LOCATION -> It's the location where you wanna reach when the players on "BLACK_LIST" show up.
3. SOUTH_LOCATION -> It's the location to go back when no players on screen.
However, as you said that you just need to walk about 5 sqms:
local BLACK_LIST = { 'player 1', 'enemy guy', 'enemy maker' } -- Players to trigger.
local PLAYERFOUND_LOCATION = { X = 12345, Y = 12345, Z = 5 } -- Location to go when players above appears on screen.
local NOPLAYERS_LOCATION = { X = 12345, Y = 12345, Z = 5 } -- Location to go when cannot found players above.
if paround(0, table.unpack(BLACK_LIST)) > 0 then
reachlocation(PLAYERFOUND_LOCATION.X, PLAYERFOUND_LOCATION.Y, PLAYERFOUND_LOCATION.Z, true)
else
if posx() ~= NOPLAYERS_LOCATION.X or posy() ~= NOPLAYERS_LOCATION.Y then
reachlocation(NOPLAYERS_LOCATION.X, NOPLAYERS_LOCATION.Y, NOPLAYERS_LOCATION.Z, true)
end
end
Posts: 6
Threads: 2
Joined: Oct 2020
Reputation:
0
12-15-2020, 08:53 AM
(This post was last modified: 12-15-2020, 08:53 AM by JohanKampe.)
Boooom, works like a charm!
Thank you!
|