Jump to content
  • 0

Using Setd/Getd


Pavi

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  03/03/12
  • Last Seen:  

Hey guys,so I was looking at the commands "Setd" and "Getd" I understand that they turn a variable into a string,

So here's what I tried...

mes "Very well please pick what kind of gaurdian you'd like to summon.";
switch(select("-^E41B17Seekers^000000:-^E41B17Pushers^000000:-^E41B17Attackers^000000:-^E41B17Warpers^000000:-^157DECKing Spawns^000000")){
 next;
 case 1:
 mes @name$;
 setd .Seekers,"SummonType";
  callfunc "Summon_Type";

case 2:
mes @name$;
setd .Pushers,"SummonType";
callfunc "Summon_Type";

setarray .Seekers[0],2680,2681,2682,2683; //Monster ID arrays
setarray .Pushers[0],2684,2685,2686,2687;
}

function script Summon_Type {
for(set .@i,0; .@i<getarraysize(getd("SummonType")); set .@i,.@i+1)
set .@menu$, .@menu$+strmobinfo(1,getd("SummonType")+[.@i])+" CM Cost- "+getd("SummonType")+[.@i]+" Point Cost- "+getd("SummonType")+[.@i]+":";
set .@selected,select(.@menu$)-1;

So,what I was aiming for,was to set the array names to one common name,so I didn't have to use a bunch of functions,I thought the best way to do this would be using the setd/getd,but the script isn't quite working right.Can anyone explain what I'm doing wrong and possibly give a clear example of the setd/getd (I tried the wiki one but I didn't quite understand it)

P.S: Sorry if this comes off as confusing,it's kinda hard to convey what I'm sorry.

Edited by Pavi
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

In your function you are trying to access the array SummonType.

You have to know first that you can't set a permanent player variable as an array :)

Getd()/Setd() don't turn a variable into a string (as you said), it get a variable from the specify name.

set .@varname$, "test";
setd ".@" + .@varname$, 5; // same as set .@test, 5;
dispbottom getd(".@" + .@varname$); // same as dispbottom .@test;

setd "$test", 5; // same as set $test, 5;
mes getd("$test"); // same as mes $test;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

Also, assuming you want to use setd/getd for other reason, lemme explain how to do it properly, 'cause the way you did is wrong.

setd / getd dynamically recall the name of a variable. This means that the variable name must be the argument of those functions.

Example:

Here you have an array of N elements, and you want to set all N elements to 1;

(Don't answer with "there are more efficient methods to do this", I know there are, I'm just showing how setd/getd works).

set .@array[0], 1;
set .@array[1], 1;
//[...]
set .@array[N], 1;

Let's use setd

for( .@i = 0; .@i < N; .@i++ )
   setd ".@array[" + .@i + "]", 1;

The same thing goes for getd.

if you want to recall index 9 of .SummonType array, all the array name and index is the "variable name", so must be everything inside getd argument.

"+getd("SummonType")+[.@i]+"

set .@i, 9;
mes "Your array has value: " + getd(".SummonType[" + .@i + "]") + " in index 9.";

It's obvious that not only munbers can be built into setd/getd function, but also the variable names themselves.

set $@pikachu, 2;

//The same as...

set .@temp$, "@pika";
setd "$" + .@temp$ + "chu", 2;

Hope it helped :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  03/03/12
  • Last Seen:  

Thank you both so much,I spent forever trying to understand setd/getd! I'll definitely practice more with these,again thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...