Total players online: 7



Take the Tour | Site Map

It is currently Tue Dec 12, 2017 12:36 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun May 14, 2017 7:39 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

No, it can't. Not until you reset the ignore list. And you won't do that, until it reaches < 1. So are you trying to build 1 random list, and keep just that list of random rune numbers from 1 to 100 and never randomizing it after that? Because that's almost as easy as this. Would you like me to show you that also? You're either A: not completely understanding or explaining what you want. Or B: Not understanding what I'm giving you. Cause the way I understand what you want, this will do exactly that. Would you like me to explain it to you?
  1.  
  2. finditem * c_ , #backpacked ; Find all items in pack.
  3. {
  4.   set %random #random % #findcnt + 1 ; Set random number between 1 and #findcnt.
  5.   set #findindex %random ; Set the #findindex to the random number found.
  6.   set %runeToRecallFrom #findid ; Set the randomly generated item number to a variable for recall.
  7.   ignoreitem #findid ; Ignore the item so it's not found in the next finditem, this making it an index of all items MINUS the last one you randomly generated. So, #findindex - 1(%random item found)
  8. }
  9. ; DO ALL YOUR CODE UNTIL #FINDCNT = 1 ;Execute whatever code you want, if you use the randomly generated rune, goto the finditem and find another randomly generated rune.
  10. IF #findcnt <= 0  ; If you run out of runes, #findcnt = 0, there are no more random runes to find, reset the ignore list.
  11.   ignoreitem reset

_________________
Image


Last edited by Scripty on Sun May 14, 2017 7:47 am, edited 1 time in total.

Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 7:46 am 
Offline
Novice Scripter
Novice Scripter

Joined: 02/04/2017 02:31
Posts: 36
Location: Turkiye
Scripty wrote:
I think it's hilarious you said "I just can't comprehend what you're doing." What is really happening, is you're not comprehending what I'm saying. I understand what you are saying absolutely and completely. You're just not doing what I said. ;)

  1. finditem %runes c_ , #backpackid
  2. {
  3.   set %random #random % #findcnt + 1
  4.   set #findindex %random
  5.   set %runeToRecallFrom #findid
  6. }
  7. ; DO ALL YOUR CODE UNTIL #FINDCNT = 1
  8.   ignoreitem reset


Where is the Array in this Code ?

You didnt understand, what he was trying to do.

He is trying to do make an array list of runes, in random order.
Like;
%ListRune1 Rune24
%ListRune2 Rune76
%ListRune3 Rune10
%ListRune4 Rune35
.
.
.
%ListRuneN RuneX

Here is the array as you describe Scripty. Another way of making random list array.

Code:
  1.  
  2. set %RuneIndex 0
  3. findItem %RuneType
  4. {
  5.     set %RuneIndex %RuneIndex + 1
  6.     set %RandomIndex #random % #findCnt + 1
  7.     set #findIndex %RandomIndex
  8.     set %List . %RuneIndex #findID
  9.     findItem %RuneType
  10. }
  11.  

_________________
There is no code that does not work. There is code that does not work as expected...


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 7:48 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

That's exactly what is happening here, the fact that you can't add a couple lines of code to make it, just means that you 2 are not understanding how it's working... Do I have to write the whole thing for you? It's only a couple of more lines... what you want, is a list of 100 randomly generated runes for emergency recall. What I gave you was a way to randomly generate a random rune down to 100 runes, never using the same one, without creating an array of the runes that is static. This one changes constantly and never uses the same rune twice. It COULD potentially use the same rune twice, ONCE in 100 runes... but what are the odds of that? 1 in 100. That's pretty good odds. Not very likely to happen. Much better than what was being attempted before. Unless you can give me a VERY solid reason why you'd want to go that far, you're just being silly. If it's really that important to you to not hit the same rune twice in a row EVER, then set a %lastRune variable. And it it's the same rune, twice at the beginning of the next round of 100 random runes, then set it to + or - 1 and just go from there. That's still a randomly generated rune, and then you could make it so the same runes are never generated twice in a row. Ever.

_________________
Image


Last edited by Scripty on Sun May 14, 2017 7:56 am, edited 1 time in total.

Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 7:53 am 
Offline
Novice Scripter
Novice Scripter

Joined: 02/04/2017 02:31
Posts: 36
Location: Turkiye
yolcu wrote:
Here is the array as you describe Scripty. Another way of making random list array.

Code:
  1.  
  2. set %RuneIndex 0
  3. findItem %RuneType
  4. {
  5.     set %RuneIndex %RuneIndex + 1
  6.     set %RandomIndex #random % #findCnt + 1
  7.     set #findIndex %RandomIndex
  8.     set %List . %RuneIndex #findID
  9.     findItem %RuneType
  10. }
  11.  


_________________
There is no code that does not work. There is code that does not work as expected...


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 7:57 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

So you're using my code and adding a line or two like I said? That's your magical way of doing the array? Well aren't you amazing. ;) By the way, the array is #findindex... just so you're aware.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 8:04 am 
Offline
Novice Scripter
Novice Scripter

Joined: 02/04/2017 02:31
Posts: 36
Location: Turkiye
Daemon wrote:
What I am doing with that code, is making an array list of all the runes, in a randomized order. This is so that other players cannot anticipate seeing my characters recalling. There are places where I've marked a rune for every 8x8 resource grid, so locations can be right next to each other and right after one another in their order. This can lead to a player seeing my character recall to one spot then another, and later seeing my character repeat the same 2 spots in the same order. I'd like to randomize the order of the runes each time I run script on the whole set of them. I have 100 runes, hence the %List . %a being 1 to 100. I should have set the random generated number from 1 to #findcnt, but typed in 100 knowing that #findcnt was 100 runes.

_________________
There is no code that does not work. There is code that does not work as expected...


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 8:06 am 
Offline
Novice Scripter
Novice Scripter

Joined: 02/04/2017 02:31
Posts: 36
Location: Turkiye
So, i think, question answered.

_________________
There is no code that does not work. There is code that does not work as expected...


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 8:12 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

Which is exactly what my code that you copy and pasted did. Yes, I did answer his question, a page and a half ago.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 9:09 am 
Offline
Novice Scripter
Novice Scripter

Joined: 02/04/2017 02:31
Posts: 36
Location: Turkiye
I dont wanna argue this with you, but u are saying that its your code.

Scripty wrote:
Which is exactly what my code that you copy and pasted did. Yes, I did answer his question, a page and a half ago.


Realy? I cant see where u answered it. Where is the array in your code?
And you wrote below that shows that u didnt understand what he wants (the bold sentence).

Scripty wrote:
That's exactly what is happening here, the fact that you can't add a couple lines of code to make it, just means that you 2 are not understanding how it's working... Do I have to write the whole thing for you? It's only a couple of more lines... what you want, is a list of 100 randomly generated runes for emergency recall. What I gave you was a way to randomly generate a random rune down to 100 runes, never using the same one, without creating an array of the runes that is static. This one changes constantly and never uses the same rune twice. It COULD potentially use the same rune twice, ONCE in 100 runes... but what are the odds of that? 1 in 100. That's pretty good odds. Not very likely to happen. Much better than what was being attempted before. Unless you can give me a VERY solid reason why you'd want to go that far, you're just being silly. If it's really that important to you to not hit the same rune twice in a row EVER, then set a %lastRune variable. And it it's the same rune, twice at the beginning of the next round of 100 random runes, then set it to + or - 1 and just go from there. That's still a randomly generated rune, and then you could make it so the same runes are never generated twice in a row. Ever.


He wants; (Read bold sentence again...)

Daemon wrote:
What I am doing with that code, is making an array list of all the runes, in a randomized order. This is so that other players cannot anticipate seeing my characters recalling. There are places where I've marked a rune for every 8x8 resource grid, so locations can be right next to each other and right after one another in their order. This can lead to a player seeing my character recall to one spot then another, and later seeing my character repeat the same 2 spots in the same order. I'd like to randomize the order of the runes each time I run script on the whole set of them. I have 100 runes, hence the %List . %a being 1 to 100. I should have set the random generated number from 1 to #findcnt, but typed in 100 knowing that #findcnt was 100 runes.


And you did never answer that.
And I wont argue this with you...

_________________
There is no code that does not work. There is code that does not work as expected...


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 10:14 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

You do realize #findindex is a 2d array yes? And that this code below doesn't work at all correctly? And mine does? Let me spell it out for you again. He's not setting the #findindex. So every time he's setting %list . %x to the SAME #FINDID. Jesus. What is wrong with you? Read it until you understand it. I wrote code that works, let me know when you get it. So I can laugh some more. haha I know the differences are subtle, but it's only a few lines of code... please, come on... I have to make you understand how this works before I give up on you. I am having a hard time believing you don't see why his doesn't work right, and mine does? You really don't see it? Look VERY closely... And that is doing EXACTLY what he wants. Mine I mean... you know, the bottom one. You're just not understanding. Psst, mine does randomize it constantly from 1-100. Over and over... to infinity. Did you even run the code?

  1. for %a 1 100
  2. set %List . %a null
  3. Finditem %RuneType C_ , %RuneStorage
  4. {
  5. GetRandomNumber:
  6. set %x #random % 100 + 1
  7. if %List . %x <> null
  8. goto GetRandomNumber
  9. set %List . %x #findid
  10. }


  1. finditem %runes c_ , #backpackid
  2. {
  3.   set %random #random % #findcnt + 1
  4.   set #findindex %random
  5.   set %runeToRecallFrom #findid
  6. }
  7. ; DO ALL YOUR CODE UNTIL #FINDCNT = 1
  8.   ignoreitem reset

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun May 14, 2017 5:56 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 12/23/2003 03:27
Posts: 1144
Location: Seige Perilous

Response to last post: I did forget to add "set #findindex %a" in my thread. Didn't even notice that. It's in the script I'm using, which is working well. I've even only randomized runes 1 - 90 and then place runes 91 - 100 in the unused %List . %Array and script is working how I want. I am also doing this with 2 different groups of runes, 50/50, so therefore at the end of one run, upon restarting the whole thing, its not possible to repeat a rune. I was trying to stay away from too much explanation of how I'm overcoming other issues, just wanted to know if there was a better method of doing what I was doing, script wise.
I understand the other way of going through the runes, randomly picking one from the remaining runes not already used and "ignored", but that did not answer the question I asked.
Although, the method you suggest does solve an issue of re-rolling the random number looking for a free location in the list array, I could recall after each random finditem on the runes, or I could simply use your method to ramdomly pick the runes and then add them to a list in the order that they randomly are selected.
Code:
  1. set %ListIndex 0
  2. {
  3. finditem %RuneType C_ , %RuneStorage
  4. set %ListIndex %ListIndex + 1
  5. set %List . %ListIndex #findid
  6. }

This would build the list I want w/o encountering the giant loop I was creating before.

_________________
While a = a
{
Scanjournal 1
If Daemon_is_attacking_you in #journal || ( you_are_attacking in #journal && Daemon in #journal )
Terminate UO
}


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Mon May 15, 2017 9:46 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2123

My whole point. At least someone gets it. Finally.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Mon May 15, 2017 1:58 pm 
Offline
Novice Scripter
Novice Scripter

Joined: 07/16/2004 22:25
Posts: 41

Groups:
I wrote up a little something ...


Code:
  1. ; makes an array %a1 -> %a100 of random numbers
  2. gosub rand_array ; create the array
  3. gosub disp_array ; display the array
  4.  
  5. sub rand_array
  6. set %lpc #lpc
  7. set #lpc 1000
  8. for %i 1 100
  9.  {
  10.  set %x %a . %i
  11.  if %x = N/A
  12.   set %x %i
  13.  set %y
  14.  set %j #random / 10 + 1
  15.  set %y %a . %j
  16.  if %y = N/A
  17.   set %y %j
  18.  set %a . %i %y
  19.  set %a . %j %x
  20.  }
  21. set #lpc %lpc
  22.  
  23. sub disp_array
  24. set %s %a1
  25. for %i 2 100
  26.  set %s %s , _ , %a . %i


Top
  Profile 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours


Who is online

Users browsing this forum: Bing [Bot], ickmanuriardri and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.