Author Topic: why dont this work?  (Read 3616 times)

0 Members and 1 Guest are viewing this topic.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
why dont this work?
« on: March 21, 2011, 07:14:25 PM »
0
set %h . #charid , gg fart

the above sets %hXXXXXXgg as fart.  (XXXXXX being current charid)

why won't the following set %3 to the value of %hXXXXXXgg??

set %3 %h . #charid , gg

can easyuo not do it like that? or am i doing it completely wrong lol.

Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +31
  • Referrals: 1
    • View Profile
Re: why dont this work?
« Reply #1 on: March 21, 2011, 08:16:32 PM »
0
Wow, that's an interesting question, as I've been testing a few things and they are all messed up:
Code: [Select]
set %c #charid
set %h . #charid , gg fart
set %hh %h . #charid , gg
set %i . %c , gg fart2
set %ii %i . %c , gg
set %3 #charid
halt

returns with the following variables:
%3: LMNOP
%C: LMNOP
%HH: N/Agg
%HILMNOPGG: fart
%II: N/Agg
%IILMNOPGG: fart2

It's almost like you can't access the %h . #charid , gg variable unless you can hardcode #charid into the name, although the following does work, as expected, since I use similar code in a number of my scripts (%jj is set to fart):

Code: [Select]
set %j . #charid fart
set %jj %j . #charid
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +31
  • Referrals: 1
    • View Profile
Re: why dont this work?
« Reply #2 on: March 21, 2011, 08:26:14 PM »
0
OK, this actually seems to work, although I don't know how well it works with what you're doing:

Code: [Select]
set %gg gg

set %cgg #charid , %gg
set %h . %cgg test
set %hh %h . %cgg

This sets the variable of %hCHARIDgg and %hh both to "test" (and using display ok %h . %cgg and %hh both display "test" as the result).  I hope this helps some, as I couldn't figure out why it wasn't working without setting gg into %gg, but I think it is that the comma used to add the gg at the end of the variable name was being read differently when trying to assign the value to %3 in your original example?
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: why dont this work?
« Reply #3 on: March 22, 2011, 10:52:10 AM »
0
Thanks.  I was wondering if I was doing it wrong, or if easyuo just wouldnt allow it to work that way.

I'm just trying to figure out how I want to save/load/store all my settings for this script.  I'm using TMs new file system, and settings will vary per character the script is ran on, but ill need to be able to run a few characters actively at once.  I thought the easiest would be to use standard variables that get loaded/created that start with the character id, that way there wont ever be a chance for multiple sets of settings for the same character (it's not needed) hopefully...

I know I've wrote another script in the past that brought up a similar situation, but with the amount of scripts I have stored, I dont even know which one it would be in! lol.


Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +31
  • Referrals: 1
    • View Profile
Re: why dont this work?
« Reply #4 on: March 22, 2011, 01:21:45 PM »
0
You're welcome!  I did a little more testing and found that both of these examples worked in assigning and retrieving the test values:

Code: [Select]
set %gg gg

set %cgg #charid , %gg
set %cgg2 #charid , gg
set %h . %cgg test
set %i . %cgg2 test2
set %hh %h . %cgg
set %ii %i . %cgg2
display ok %hh
display ok %ii
halt

I've mainly used #charid in variable names with the mining scripts, so I can use just one base script and open it 3 or 4 times, press play, and watch the ingots stack up!  I'm sure there are many other uses for it as well, but this alone was more than worth the effort...
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: why dont this work?
« Reply #5 on: March 22, 2011, 02:28:14 PM »
0
this is what i've come up with so far ;/

   set !x  #charid , secondaryabilityx
   set !y  #charid , secondaryabilityy
   set % . !x #contposx
   set % . !y #contposy
   gosub scanspecial % . !x % . !y

but,  i think i'm changing it.  the scanspecial sub will scan any toggleable spell/skill icon and return whatever combination of pixcol code that it comes up with.  that worked ok for building my database of pixel codes quickly i guess.  from here i guess i should just expand that sub to return/set variables or what not as needed to compact the code a little.

i'm working on a little pvm helper script, kinda like Twinkle McNugget badass one, but i'm not going all out like he did so it wont quite be badass!  i suppose more like lite pvm lite ;P  i've got a simple one that ive been using for a long time and it just needs to be improved a little.  the main part was this save/load of settings.  i always had to reset everything up, and when linking 2-4 clients together to do things it got annoying always having to set things up! lol.

Scrripty

  • Guest
Re: why dont this work?
« Reply #6 on: March 22, 2011, 02:30:31 PM »
0
Don't forget the use of namespaces so you don't have to use #charid in your variables.  You can call a namespace with #charid so your vars are unique based on your #charid without needing to use #charid in your vars.  Makes it nice and easy to create tons of vars quickly for each character based on #charid without actually using #charid in your vars.

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: why dont this work?
« Reply #7 on: March 22, 2011, 03:02:51 PM »
0
Don't forget the use of namespaces so you don't have to use #charid in your variables.  You can call a namespace with #charid so your vars are unique based on your #charid without needing to use #charid in your vars.  Makes it nice and easy to create tons of vars quickly for each character based on #charid without actually using #charid in your vars.

to be honest this is the FIRST script I've used namespaces in lol...  I always thought it was confusing, but i read TM's post last night and so far I have like 6 subs using them :D  It's soooo great and I don't have all these floating worthless temp variables haha.  I just edited my sub and eliminated those 4 lines that i had in there, it works now perfect. 

I'm doing this right now:
set ! . #charid , primaryability #contposx , _ , #contposy

is that what you mean?

Scrripty

  • Guest
Re: why dont this work?
« Reply #8 on: March 22, 2011, 03:49:56 PM »
0
No, I mean:

Code: [Select]
namespace push
namespace local OMG . #charid
[YOUR VARIABLES HERE NOT USING #CHARID]
namespace pop

You're gonna kick yourself in your own ass when you see how easy namespaces are.  This will shine a light on it for you and you'll get it:

"Think of namespaces as a seperate container for your variables ensuring that even like named variables are seperate when put into unique namespaces."  Read that over about 10 times and look at that example.  Think of a namespaces as 2 jars on the ground, one is named OMG . #charId and the other is named OMG . #charId, they are both seperate characters with different ids, now put the same variables into each one.  You can write to each namespace seperately and the variables wont overwrite each other because they are in SEPERATE JARS even tho they use the same name and the same code.  You're using a variable to call each JAR or NAMESPACE seperately so the vars are unique to their respective JAR/NAMESPACE.  Get it? :)  Like this:

Code: [Select]
set %OMGNamespace OMG . #charid

namespace push
namespace local %OMGNamespace
set %OMGVar #charid
namespace pop

If you run that code, and swap to a second client while running it, there will be TWO namespaces, one named OMG . #charid for EACH client.  And the variable in each one will be different because it was swapped to another char, the namespace name became different, and the %OMGVar #charid is different in the second or swapped namespace using the same code.
« Last Edit: March 22, 2011, 04:12:23 PM by Scripty »

Offline OMGBurgersTopic starter

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: why dont this work?
« Reply #9 on: March 22, 2011, 04:43:56 PM »
0
I kinda understand what you're saying, but I think I need to mess w/ the namespace things a bit more to understand them more.  I don't totally understand them & should read up a lil more haha.

I see what youre saying about how i can define the namespaces via charid though, which is great.

I was under the assumption you can only have one at a time for some reason, that you have to clear/pop when youre done usin em, but after i read what you typed I see you can have multiple namespaces at once that hold data, and switch between them flawlessly i guess.  Thats why I was doing the whole % . #charid , primaryability way lol.

So I understand how I can make the code a TON easier, now I should read up on namespace again, and i guess i'll eventually grasp it better!

Thanks a TON for your help! :D

+rep for your help and helping me with this haha

Tags: