Author Topic: Creating variables on the fly.  (Read 3853 times)

0 Members and 1 Guest are viewing this topic.

Offline camotbikTopic starter

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Creating variables on the fly.
« on: August 14, 2011, 06:40:07 PM »
0
Is something like this even possible?

Code: [Select]

menu List Create EUOListBox1 0 0 249 520
finditem * C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
  event property #findid
  str pos #property  $ 1
  set %lenght #strres - 1
  str left #property  %lenght
  set %name #strres
  if #findstack = 1
  {
    if % , #findtype , #findcol , ammount = N/A || % , #findtype , #findcol , ammount = 0
    {
     set % , #findtype , #findcol , ammount #findstack
     menu List Add EUOListBox1 % , #findtype , #findcol , ammount %name
     }
    else
      set % , #findtype , #findcol , ammount  % , #findtype , #findcol , ammount + #findstack
  }
  else
    menu List Add EUOListBox1 %name
}
  menu Window Size 246 561
  menu Show
halt
« Last Edit: August 15, 2011, 01:48:51 AM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Creating variables on the fly.
« Reply #1 on: August 14, 2011, 09:27:51 PM »
0
The Question is for your Example, is that needet?
Example of my Doom Script for Menu:
Code: [Select]
str pos #property $
set %helper #strres - 1
str left #property %helper
set %Artifactname #strres
menu List Add EUOListBox1 %Artifactname
Making infinite Amount of %Variables wich you only using one time is just a mess of running out of Ram.. Or am I wrong?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13305
  • Activity:
    0.8%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Creating variables on the fly.
« Reply #2 on: August 14, 2011, 09:30:34 PM »
0
you've almost got it.  EUO supplies to different kinds of reference operators.  There's the right-associative "," and the left-associative "."

So if you change your line:

Code: [Select]
set % , #findtype , #findcol , ammount #findstack

to this:

Code: [Select]
set % . #findtype , #findcol , ammount #findstack

Then I think it'll work the way you are thinking.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Creating variables on the fly.
« Reply #3 on: August 14, 2011, 10:28:22 PM »
0
you've almost got it.  EUO supplies to different kinds of reference operators.  There's the right-associative "," and the left-associative "."

So if you change your line:

Code: [Select]
set % , #findtype , #findcol , ammount #findstack

to this:

Code: [Select]
set % . #findtype , #findcol , ammount #findstack

Then I think it'll work the way you are thinking.

Yeah of Course. But behind the Back(And i know that about talking before with Camotbik in icq) it would work, but doesnt have any reason more than creating a lot of Variables with a one usage.
and
Code: [Select]
set % . #findtype , #findcol , ammount #findstack
istn there a , missing?
Code: [Select]
set % . #findtype , #findcol , ammount ,#findstack

Crome

Offline camotbikTopic starter

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Creating variables on the fly.
« Reply #4 on: August 15, 2011, 06:12:38 AM »
0
it seems that EUO doesnt work the way i was planing

Code: [Select]
finditem * C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
    set %FT #FindType
    set %FC #FindCol
    set %TC %FT , %FC
    if %TC , Allready_in_list = #TRUE
     DISPLAY IT WORKS
    set %TC , Allready_in_list = #TRUE
}
What you witness -- is whatver..
uogamers hybrid.

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 822
  • Activity:
    0.2%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +156
  • Referrals: 3
    • View Profile
Re: Creating variables on the fly.
« Reply #5 on: September 03, 2011, 11:12:10 AM »
0
it seems that EUO doesnt work the way i was planing

Code: [Select]
finditem * C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
    set %FT #FindType
    set %FC #FindCol
    set %TC %FT , %FC
    if %TC , Allready_in_list = #TRUE
     DISPLAY IT WORKS
    set %TC , Allready_in_list = #TRUE
}

I've worked a little with associativity in a bod script I wrote, I use it to get item types from bod properties...

Imagine the Bod i'm talking about is to craft Bronze Shields. I have a preset list of item types. Bronze Shield will be there like this:

set !_Bronze_Shield GIK

I use strings to get the item name from the bod. I have a sub that will return Bronze , #spc , Shield from the string, which will be added to a variable:

set !item_name Bronze , #spc , Shield


Then I have another sub that I call using the !item_name var:

gosub gettype !item_name

this sub will work with the !item_name (Bronze Shield) and result in a string with underscore:
set !string Bronze_Shield

I then set the result like this before returning:

set #result !_ . !string
return #result

so the #result var will contain exactly the !_Bronze_Shield var which is GIK

From all the testing I did with associativity, the best (only?) way to make this work is to combine a maximum of 2 strings each time to get a resulting var.
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Creating variables on the fly.
« Reply #6 on: September 03, 2011, 03:21:10 PM »
0
it seems that EUO doesnt work the way i was planing

Code: [Select]
finditem * C_ , #backpackid
for #FINDINDEX 1 #FINDCNT
{
    set %FT #FindType
    set %FC #FindCol
    set %TC %FT , %FC
    if %TC , Allready_in_list = #TRUE
     DISPLAY IT WORKS
    set %TC , Allready_in_list = #TRUE
}



Error in this line:     if %TC , Allready_in_list = #TRUE
if #findtype = ABC and #findcol=22 then this evaluates to: if ABC22Allready_in_list = #TRUE
Which of course will always be false as ABC22Allready_in_list is not a valid var name and thierfor holds no value.

What you need to do is go one step further in the abstraction.

Code: [Select]
   set %TC %FT , %FC , Allready_in_list
    if % . %TC  = #TRUE
     DISPLAY IT WORKS
    set % . %TC  #TRUE  ; no =


see how if % . %TC  = #TRUE  now evaluates to
if %ABC22Alleady_in_list = true

which is of course is a valid var name.
« Last Edit: September 03, 2011, 03:23:28 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline camotbikTopic starter

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Creating variables on the fly.
« Reply #7 on: September 04, 2011, 05:24:57 AM »
0
Well thank you EN, now I've finally got further in this.

Code: [Select]
event SysMessage Target storage
set #targcurs 1
while #targcurs <> 0
 wait 1
set %storage #ltargetid
set #lobjectid %storage
while #contid <> %storage
{
event macro 17
wait 5
}
menu List Create EUOListBox1 0 0 249 520
finditem * C_ , %storage
for #FINDINDEX 1 #FINDCNT
{
  set %FT #FindType
  set %FC #FindCol
  set %TC %FT , %FC
  event property #findid
  str pos #property  $ 1
  set %lenght #strres - 1
  str left #property  %lenght
  set %name #strres
  if #findstack = 1
  {
    if % . %TC  = #TRUE
    {
      set %TC . 1 %TC . 1 + #FINDSTACK
         ;display %name %TC . 1  ; for debuging purposes
     }
    else
    {
    set %TC . 1 #FINDSTACK
    set % . %TC #TRUE
     menu List add EUOListBox1 %TC . 1 %name
     }
  }
  else
    menu List Add EUOListBox1 %name
}
  menu Window Size 246 561
  menu Show
halt

But I'm still new to the menus and I've have now a menu issue.
for example.
Code: [Select]
menu List Create EUOListBox1 0 0 249 520
menu List Add EUOListBox1 Test %count
for %i 1 5
{
set %count %count + 1
}
  menu Window Size 246 561
  menu Show
halt
I've need to get this some how working, to complete the above script..

The thing is that the variable isn't updating after I've popup the menu window. It Sets the %count that it has on the exact moment that I've set it,  and I'm sure there is a possible way to do this, but I'm currently not familiar with it..
Ps; and i know that i have to set the "menu List Add EUOListBox1 Test %count" after the counting, but i've need this to work this way, so i haven't have to write all the item names by hand..

This could be easily solved if there was a way to create an own set queue like in #findindex, to execute your prefered lines..
« Last Edit: September 04, 2011, 06:43:01 AM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Creating variables on the fly.
« Reply #8 on: September 04, 2011, 06:52:57 AM »
0
Code: [Select]
menu List Create EUOListBox1 0 0 249 520
for %i 1 5
{
menu List Add EUOListBox1 Test %i
}
  menu Window Size 246 561
  menu Show
halt
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline camotbikTopic starter

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Creating variables on the fly.
« Reply #9 on: September 04, 2011, 07:22:51 AM »
0
I know this works this way, but I need to get it working the way I've showed above, some how...
What you witness -- is whatver..
uogamers hybrid.

Offline camotbikTopic starter

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Creating variables on the fly.
« Reply #10 on: September 04, 2011, 09:33:21 AM »
0
Ok now so the people would understand what it was all about.. Here's a running test version.

Code: [Select]
menu Clear
menu Window Title Testing stats
menu Window Color BtnFace
menu Window Size 246 561
menu Font Transparent #true
menu Font Align Right
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style
menu Font Color WindowText
menu Font Transparent #false
menu Font Align Left
menu Text EUOLabel1 4 524 Press start to proceed
menu Font Name Default
menu Font Color Black
menu Font Name Default
menu Font Color Black
menu Button Start 132 524 109 33 Start
menu Show
start:
while #MENUBUTTON <> START
{
  wait
}
menu List Create EUOListBox1 0 0 249 520
set #MENUBUTTON N/A
menu Delete EUOLabel1
menu Text EUOLabel1 4 524 Select container
set #targcurs 1
while #targcurs <> 0
  wait 1
set %storage #ltargetid
set #lobjectid %storage
while #contid <> %storage
{
  event macro 17
  wait 5
}
menu Delete EUOLabel1
menu Text EUOLabel1 4 524 Creating a list..
finditem * C_ , %storage
while #findcnt > 0
{
  set %FT #FindType
  finditem %FT C_ , %storage
  while #findcnt > 0
  {
    set %FC #FindCol
    set %kol 0
    set %kolstack 0
    for #FINDINDEX 1 #FINDCNT
    {
      if #FINDCOL = %FC
      {
        set %kol %kol + 1
        event property #findid
        str pos #property $ 1
        set %lenght #strres - 1
        str left #property %lenght
        set %name #strres
        if #findstack > 1
        {
          str Len #findstack
          set %lenght #strres + 1
          str Del %name 1 %lenght
          set %kol 0
          set %kolstack %kolstack + #findstack
        }
        ignoreItem #FINDID
      }
    }
    if %kol > 0
      menu List add EUOListBox1 %kol #strres ;%FT %FC
    if %kol = 0
      menu List add EUOListBox1 %kolstack #strres ;%FT %FC
    finditem %FT C_ , %storage
  }
  finditem * C_ , %storage
}
ignoreItem reset
menu Delete EUOLabel1
menu Text EUOLabel1 4 524 List created.
goto start
« Last Edit: September 04, 2011, 10:27:19 AM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Tags: