Dictionary/Array

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Dictionary/Array

Post by Tharon »

Hallo, I want to show the player if a buff is active.
The active Spells are in a dictionary.

I start the script with a gump in tempmod function:

Code: Select all

function tempmod(who, dict, duration, spellname, incrementDictValues := 1)

  set_critical(1);
    var activeSpells:= GetObjProperty (who, CPROP_MAGIC_ACTIVESPELLS);

    if (activeSpells == error)
      activeSpells:= dictionary;
    endif

    var  process := start_script( ":magic:testgump", who);
    var  gumpid := process.pid;
   
    if (activeSpells.exists(spellname))
      err.errortext:= "already under influence";
      set_critical (0);
      return err;
    endif
   ...

Code: Select all

se uo;
use os;

var layout:= array(
 "nomove",
 "noclose",
 "GumpPic 4 28 2256"
  );

var layout1:= array(
 "nomove",
 "noclose",
 "GumpPic 48 28 2192"
  );

var layout2:= array(
 "nomove",
 "noclose",
 "GumpPic 92 28 2255"
 );

var layout3:= array(
 "nomove",
 "noclose",
 "GumpPic 136 28 2249"
 );

var layout4:= array(
 "nomove",
 "noclose",
 "GumpPic 180 28 2248"
 );
 
var data:= array(
);


program gumpi(who)

var spells := dictionary;
    spells := GetObjProperty(who, "magic_activeSpells");
var keys   := spells.keys();

  foreach spruch in (keys)  

        if(spruch == "Segen")
            SendDialogGump (who, layout, data);
         endif

        if(spruch == "Massensegen")
           SendDialogGump (who, layout1, data); 
        endif

        if(spruch == "Staerke")
           SendDialogGump (who, layout2, data); 
        endif
 
        if(spruch == "Schlaeue")
           SendDialogGump (who, layout3, data); 
        endif

        if(spruch == "Behaendigkeit")
           SendDialogGump (who, layout4, data); 
        endif
    
  endforeach

endprogram

I do not know what to do, but only a few of them work.
It is dependent what i cast first, second...
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Dictionary/Array

Post by CWO »

Is only one appearing when you want multiple ones? This is due to SendDialogGump. This is the only way to send gumps but it sends the gump and waits for the gump to be closed before moving on. You would have to add your layouts together before sending the gump and send it only once like this...

Code: Select all

use uo;
use os;

var layout:= array{
"nomove",
"noclose"
};

var data:= array{
};


program gumpi(who)

var spells := dictionary;
    spells := GetObjProperty(who, "magic_activeSpells");
var keys   := spells.keys();
var x := 4;

  foreach spruch in (keys) 
        if(spruch == "Segen")
            layout.append("GumpPic x 28 2256");
            x := x+44;
         endif

        if(spruch == "Massensegen")
           layout.append("GumpPic x 28 2192");
           x := x+44;
        endif

        if(spruch == "Staerke")
           layout.append("GumpPic x 28 2255");
           x := x+44;
        endif

        if(spruch == "Schlaeue")
           layout.append("GumpPic x 28 2249");
           x := x+44;
        endif

        if(spruch == "Behaendigkeit")
           layout.append("GumpPic x 28 2248");
           x := x+44;
        endif
  endforeach
  if (x > 4)
    SendDialogGump(who, layout, data);
  endif
endprogram
Try this out and see if this does what you want.
Post Reply