I'm attempting to store location coordinates in a list (works fine) so that I can write an if statement to determine where I want my character to move (and eventually, move there and maybe do actions).
I started by creating the list and putting some values in it:
if XYCoords[0] = 1200 and XYCoords[1] = 2400
//Do something
clearlist 'XYCoords'
pushlist 'XYCoords' '1000'
pushlist 'XYCoords' '2400'
elseif XYCoords[0] = 1000 and XYCoords[1] = 2400
//Do something else
endif
So far I get told that "Comand XYCoords[0] doesn't exist." So it's reading this as a command and not a compare statement. I have tried apostrophes around the numbers, double equals, swapping the numbers and the list reference, creative maneuvers with the list command, etc. Anyone have some insight on either how I make the syntax match what it's looking to see, or is there a better way to store numeric values for processing later in the script?
Using a 2-element list to store location works fine as long as I'm comparing x or y to the list elements. The problem seems to be that I want to use the list to moderate the script, and it seems UOSteam doesn't allow for the list reference to be on the left of the comparison operator.
I am able to walk to the desired position using the following:
while x != XYCoords[0] or y != XYCoords[1]
if x < XYCoords[0]
run 'east'
endif
if x > XYCoords[0]
run 'west'
endif
if y < XYCoords[1]
run 'south'
endif
if y > XYCoords[1]
run 'north'
endif
pause 100
endwhile
That code actually lives in a separate macro, and I call this macro from the main macro, so I can make one line playmacro call instead of repeating the same 15 lines over and over. What I'm looking to do here is use the "desired" location to tell my if/else logic what to evaluate. The flowchart logic is something like this:
If desired location is 1
recall to location 1
unload resources
set desired location to 2
elseif desired position is 2
run to location 2
playmacro 'gathering resources'
set desired location to 3
elseif desired location is 3
run to...
endif
I don't want to rely on the current x/y because there may be actions to be taken before moving. But unless I can find a way to put the list reference on the left of that equals, I may hafta restructure it.
Just to close the loop on this, I did end up giving in and using my x and y coords. It seems that UOS lacks any method for storing "variables" because it doesn't allow you to compare the list element or alias to something else. I was able to structure my script such that the desired actions at each x/y coord could be executed and then the character walks to the next location.
Tbh I'm probably pushing the limits by using separate macros as function calls. But I am still a little curious if one could write to a book and use that for storage variables.
Not sure if this helps you any, but here is a quick script I wrote that changes the XYCoords based on your player's X/Y. Test in in Luna if you'd like. Loop on or off, on will run in circles, off will run to the next spot only.
//Start ontop of or directly north or south of the Luna moongate
@createlist 'XYCoords'
@clearlist 'XYCoords'
//Set Coords to SE Corner
if x 'self' == 1015
if y < 538 and y >= 499
sysmsg 'Spot 1'
@pushlist 'XYCoords' '1015'
@pushlist 'XYCoords' '538'
endif
endif
//Set Coords to SW Corner
if @x <= 1015 and @x > 961
if @y == 538
sysmsg 'Spot 2'
@pushlist 'XYCoords' '961'
@pushlist 'XYCoords' '538'
endif
endif
//Set Coords to NW Corner
if @x == 961
if @y <= 538 and @y > 499
sysmsg 'Spot 3'
@pushlist 'XYCoords' '961'
@pushlist 'XYCoords' '499'
endif
endif
//Set Coords to NE Corner
if @x >= 961 and @x < 1015
if @y == 499
sysmsg 'Spot 4'
@pushlist 'XYCoords' '1015'
@pushlist 'XYCoords' '499'
endif
endif
//Running
while @x != XYCoords[0] or @y != XYCoords[1]
while @x < XYCoords[0]
run 'east'
pause 75
endwhile
while @x > XYCoords[0]
run 'west'
pause 75
endwhile
while @y < XYCoords[1]
run 'south'
pause 75
endwhile
while @y > XYCoords[1]
run 'north'
pause 75
endwhile
pause 100
endwhile
As far as storing variables by using books, I don't see anything in the documentation to do this.. You may try using
Xionu wrote: ↑September 17th, 2020, 3:58 pm
Not sure if this helps you any, but here is a quick script I wrote that changes the XYCoords based on your player's X/Y. Test in in Luna if you'd like. Loop on or off, on will run in circles, off will run to the next spot only.
That's a neat little proof-of-concept script, and it closely resembles the setup I've built. I have a 'function' that does the second part (run, step by step, toward the XYCoords list) and I use clearlist, pushlist, pushlist prior to calling it from my main script. Biggest add is that I included non-cardinal directions. Need to write some "good" unstuck logic in it now. The taming training macros out there are decent, but eventually they give up.
Xionu wrote: ↑September 17th, 2020, 3:58 pmAs far as storing variables by using books, I don't see anything in the documentation to do this..
I also saw nothing in the "all-inclusive" documentation describing writing to books, but I also see a recent post in this forum where there exists the capability of copying books, so perhaps reading and disseminating the data from the book might be useful for storing script values.
Such 4th wall breaking tho! Imagine writing nonsense into a book that stored information for a script that was driving you in real life...
Xionu wrote: ↑September 17th, 2020, 3:58 pm
Not sure if this helps you any, but here is a quick script I wrote that changes the XYCoords based on your player's X/Y. Test in in Luna if you'd like. Loop on or off, on will run in circles, off will run to the next spot only.
That's a neat little proof-of-concept script, and it closely resembles the setup I've built. I have a 'function' that does the second part (run, step by step, toward the XYCoords list) and I use clearlist, pushlist, pushlist prior to calling it from my main script. Biggest add is that I included non-cardinal directions. Need to write some "good" unstuck logic in it now. The taming training macros out there are decent, but eventually they give up.
Xionu wrote: ↑September 17th, 2020, 3:58 pmAs far as storing variables by using books, I don't see anything in the documentation to do this..
I also saw nothing in the "all-inclusive" documentation describing writing to books, but I also see a recent post in this forum where there exists the capability of copying books, so perhaps reading and disseminating the data from the book might be useful for storing script values.
Such 4th wall breaking tho! Imagine writing nonsense into a book that stored information for a script that was driving you in real life...
I believe the book copy macro you're referring to uses inscription in order to copy the books (not the actual text inside the book).
Something that you may find useful is using a runebook with named runes. These runes can act as variables, while still static, they are variables none the less.
You can drop the rune from the book and use something like:
You can go as far as dropping and renaming them with a macro if you'd like, this sort of makes them non-static, but in the macro they will only be static.
You are correct; when I went back and looked it was using inscription to offload the text copy to the server. I like the rune-as-variables concept, as it should prove more user-friendly than naming animals.