Page 1 of 1
Inscription 099 POL
Posted: Thu Feb 06, 2014 4:31 am
by Harley
I use Zulu Hotel inscription, and there is a problem in 099 version
This Menu for inscript from Spell Book to scrolls
When I click inscript target at Spell Book, there create menu with:
var tmenu := CreateMenu( "Select a circle to inscribe");
After, I click at the any Circle, and there is error in:
var hischoice := SelectMenuItem2(who, tmenu2 ); // .index; // );
4 error{ errortext = "Object does not support members" }
Code: Select all
function MakeAndProcessMenu( who , spellbook )
var circles := { };
foreach spell in EnumerateItemsInContainer(spellbook)
var elem := FindConfigElem(config_file, spell.objtype);
var thecircle := GetConfigInt(elem, "Circle");
circles[thecircle] := 1;
print(" circles[thecircle] := 1; ");
endforeach
var i;
var tmenu := CreateMenu( "Select a circle to inscribe");
if( tmenu.errortext )
print("1 "+ tmenu.errortext );
return 0;
endif
for (i := 1; i <= 8; i := i + 1)
// if (circles[i] == 1)
// if( circles[i] )
var addm := AddMenuItem( tmenu, 0x20bf + i, "Circle " + cstr(i) + " spells");
if(!addm)
print(addm.errortext);
endif
// endif
// SleepMS(5);
endfor
var firstchoice := SelectMenuItem2( who, tmenu ).index; // );
// if (!firstchoice.index)
if( !firstchoice )
print("2 "+ firstchoice.errortext );
return 0;
endif
var tmenu2 := CreateMenu("Select a spell to inscribe");
if( !tmenu2 )
print("3 "+ tmenu2.errortext );
return 0;
endif
var scrolls_objtype := {};
foreach spell in EnumerateItemsInContainer(spellbook)
print(" FIND SPELLBOOK ");
var elem := FindConfigElem(config_file, spell.objtype);
var thecircle := GetConfigInt(elem, "circle");
if (thecircle == firstchoice.objtype - 0x20bf)
var spellname := GetConfigString(elem, "name");
var thetype := GetConfigInt(elem, "graphic");
scrolls_objtype.append( spell.objtype );
AddMenuItem(tmenu2, thetype, spellname);
Print(" AddMenuItem ");
endif
endforeach
var hischoice := SelectMenuItem2(who, tmenu2 ); // .index; // );
if( !hischoice.Index )
// if( !hischoice )
print("4 "+ tmenu2.errortext );
return 0;
else
return scrolls_objtype[hischoice.index];
endif
endfunction
Please, help me some one who understand where is an error and can help to fix it!
With best regards!
Re: Inscription 099 POL
Posted: Thu Feb 06, 2014 9:13 am
by Zik
Change this
Code: Select all
foreach spell in EnumerateItemsInContainer(spellbook)
print(" FIND SPELLBOOK ");
var elem := FindConfigElem(config_file, spell.objtype);
var thecircle := GetConfigInt(elem, "circle");
if (thecircle == firstchoice.objtype - 0x20bf)
var spellname := GetConfigString(elem, "name");
var thetype := GetConfigInt(elem, "graphic");
scrolls_objtype.append( spell.objtype );
AddMenuItem(tmenu2, thetype, spellname);
Print(" AddMenuItem ");
endif
endforeach
var hischoice := SelectMenuItem2(who, tmenu2 ); // .index; // );
if( !hischoice.Index )
// if( !hischoice )
print("4 "+ tmenu2.errortext );
return 0;
else
return scrolls_objtype[hischoice.index];
endif
to
Code: Select all
foreach spell in EnumerateItemsInContainer(spellbook)
print(" FIND SPELLBOOK ");
var elem := FindConfigElem(config_file, spell.objtype);
var thecircle := GetConfigInt(elem, "circle");
if (thecircle == firstchoice.objtype - 0x20bf)
var spellname := GetConfigString(elem, "name");
var thetype := CInt(GetConfigInt(elem, "graphic"));
scrolls_objtype.append( spell.objtype );
AddMenuItem(tmenu2, thetype, spellname);
Print(" AddMenuItem ");
endif
endforeach
if( scrolls_objtype.size() < 1 )
Print(" No Scrolls in SB! ");
return 0;
endif
var hischoice := SelectMenuItem2(who, tmenu2 ); // .index; // );
if( !hischoice.Index )
// if( !hischoice )
if( !tmenu2 || tmenu2 == error)
print("4 "+ tmenu2.errortext );
return 0;
endif
else
return scrolls_objtype[hischoice.index];
endif
Hope it'll help
Re: Inscription 099 POL
Posted: Thu Feb 06, 2014 11:56 am
by Harley
Zik, thank u! You was right!
There is print:
No Scrolls in SB!
But how it can be? In spell book all spells

- !1.jpg (18.72 KiB) Viewed 16973 times
I don't understand...
Re: Inscription 099 POL
Posted: Thu Feb 06, 2014 2:25 pm
by Zik
Print(" No Scrolls in SB! ");
I should have written "array is empty".
Look here:
Code: Select all
var firstchoice := SelectMenuItem2( who, tmenu ).index; // );
and from pol docs: .index = 1-based index within the menu of the selection.
Try it without .index:
Code: Select all
var firstchoice := SelectMenuItem2( who, tmenu ); // );
It should help.
You are trying to use if (thecircle == firstchoice
.objtype - 0x20bf)
it's impossible since you've assigned only an integer to firstchoice.
Re: Inscription 099 POL
Posted: Thu Feb 06, 2014 3:16 pm
by Harley
Zik, I have tried this:
Code: Select all
var firstchoice := SelectMenuItem2( who, tmenu );
And have tried to delete this
Code: Select all
if (thecircle == firstchoice.objtype - 0x20bf)
After, I have tried replace to this
Nothing works..
Edited
But! When I add this:
Code: Select all
if ( thecircle == firstchoice )
var spellname := GetConfigString(elem, "name");
var thetype := CInt(GetConfigInt(elem, "graphic"));
scrolls_objtype.append( spell.objtype );
AddMenuItem(tmenu2, thetype, spellname);
Print(" AddMenuItem ");
endif
"Array is empty!" Was disappeared, but after nothing happened..
Re: Inscription 099 POL
Posted: Thu Feb 06, 2014 6:05 pm
by Zik
Do you see second menu? I made a mistake in print 4.
Try this one, I rewrote your function a little bit:
Code: Select all
function MakeAndProcessMenu( who , spellbook )
var circles := {};
foreach scroll in EnumerateItemsInContainer(spellbook)
var elem := FindConfigElem(config_file, scroll.objtype);
var thecircle := GetConfigInt(elem, "Circle");
circles.append(thecircle);
endforeach
if (circles.size()<1)
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
var tmenu := CreateMenu( "Select a circle to inscribe");
foreach circle in circles
var addm := AddMenuItem( tmenu, 0x20bf + circle, "Circle "+circle+" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
endforeach
var circle_choice := SelectMenuItem2( who, tmenu ); // what this menu shows?
if( circle_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( circle_choice == error )
SendSysMessage( who, "Error picking a circle: "+circle_choice.errortext, 3, 32 );
return 0;
endif
var tmenu2 := CreateMenu("Select a spell to inscribe"),
scrolls_name := {},
scrolls_objtype := {};
foreach scroll in EnumerateItemsInContainer(spellbook)
var elem := FindConfigElem(config_file, scroll.objtype);
var thecircle := GetConfigInt(elem, "Circle");
if (thecircle == circles[circle_choice.index])
var spellname := GetConfigString(elem, "name");
var thetype := GetConfigInt(elem, "graphic");
scrolls_objtype.append( scroll.objtype );
scrolls_name.append( spellname );
AddMenuItem(tmenu2, thetype, spellname);
endif
endforeach
var scroll_choice := SelectMenuItem2(who, tmenu2 ); // what this menu shows?
if( scroll_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( scroll_choice == error )
SendSysMessage( who, "Error picking a spellscroll: "+scroll_choice.errortext, 3, 32 );
return 0;
else
SendSysMessage( who, "You will make a "+scrolls_name[scroll_choice.index]+" scroll.", 3, 67 );
return scrolls_objtype[scroll_choice.index];
endif
endfunction
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 1:26 am
by Harley
Zik, I have changed it, and there is:
When I click inscription and spellbook:
"Spellbook is empty."
If I
Code: Select all
/*
if (circles.size()<1)
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
*/
There is next error:
"Error picking a circle: Client is busy, or menu is empty"
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 3:48 am
by Zik
So let's find out why menu (or circles array) is empty:
Code: Select all
var circles := {};
foreach scroll in EnumerateItemsInContainer(spellbook)
var elem := FindConfigElem(config_file, scroll.objtype);
SendSysMessage( who, "Debug1: "+elem+" / "+elem.errortext, 3, 32 );
var thecircle := GetConfigInt(elem, "Circle");
SendSysMessage( who, "Debug2: "+thecircle+" / "+thecircle.errortext, 3, 32 );
circles.append(thecircle);
endforeach
if (circles.size()<1) // Don't comment this check, it'll we be of use if a SB is really empty.
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
What will be written as errors this time?
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 4:40 am
by Harley
Zik, there is same error:
"Spellbook is empty."
Nothing new..
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 10:17 am
by Zik
Any lines before that message? Something like: "Debug2: 8 /...". Or "Debug1: {config element reference}/..." ?
Add these lines to the first loop:
Code: Select all
SendSysMessage( who, "scroll objtype: "+scroll.objtype, 3, 32 );
Sleepms(10);
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 10:45 am
by Harley
Zik wrote:Any lines before that message? Something like: "Debug2: 8 /...". Or "Debug1: {config element reference}/..." ?
Add these lines to the first loop:
Code: Select all
SendSysMessage( who, "scroll objtype: "+scroll.objtype, 3, 32 );
Sleepms(10);
In fact of the matter is that nothing is written!
I have add
Code: Select all
foreach scroll in EnumerateItemsInContainer(spellbook)
SendSysMessage( who, "scroll objtype: "+scroll.objtype, 3, 32 );
Sleepms(10);
var elem := FindConfigElem(config_file, scroll.objtype);
SendSysMessage( who, "Debug1: "+elem+" / "+elem.errortext, 3, 32 );
var thecircle := GetConfigInt(elem, "Circle");
SendSysMessage( who, "Debug2: "+thecircle+" / "+thecircle.errortext, 3, 32 );
circles.append(thecircle);
endforeach
And nothing!!! How it can be?
p.s. This functions called from:
Code: Select all
if( item.objtype == UOBJ_SPELLBOOK )
MakeAndProcessMenu( who, item );
elseif...
I have open the spellbook in trade menu and what I saw:
Re: Inscription 099 POL
Posted: Fri Feb 07, 2014 4:20 pm
by Zik
Hmm, check it out:
http://docs.polserver.com/pol099/objref.php#Spellbook
I've made another function for you, but it's vital that lines "Name ..." are the same in both configs - Spells.cfg and your "config_file"(with scrolls' objtypes).
[*]
Code: Select all
function MakeAndProcessMenu( who , spellbook )
var all_spells := spellbook.Spells(),
circles := {},
names := {},
spells_cfg := ReadConfigFile("spells");
if (all_spells.size()<1)
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
foreach spell in all_spells
circles.append(spells_cfg[spell].Circle);
names.append(spells_cfg[spell].Name);
endforeach
var tmenu := CreateMenu( "Select a circle to inscribe");
foreach circle in circles
var addm := AddMenuItem( tmenu, 0x20bf + circle, "Circle "+circle+" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
endforeach
var circle_choice := SelectMenuItem2( who, tmenu ); // what this menu shows?
if( circle_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( circle_choice == error )
SendSysMessage( who, "Error picking a circle: "+circle_choice.errortext, 3, 32 );
return 0;
endif
var tmenu2 := CreateMenu("Select a spell to inscribe"),
spell_names := {},
scroll_types := {};
foreach scroll in GetConfigIntKeys(config_file);
var spellname := config_file[scroll].name;
if ( spellname in names && config_file[scroll].Circle == circles[circle_choice.index])
spell_names.append( spellname );
scroll_types.append( scroll );
AddMenuItem(tmenu2, config_file[scroll].graphic, spellname);
endif
endforeach
var scroll_choice := SelectMenuItem2(who, tmenu2 ); // what this menu shows?
if( scroll_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( scroll_choice == error )
SendSysMessage( who, "Error picking a spellscroll: "+scroll_choice.errortext, 3, 32 );
return 0;
else
SendSysMessage( who, "You will make a "+spell_names[scroll_choice.index]+" scroll.", 3, 67 );
return scroll_types[scroll_choice.index];
endif
endfunction
If you add spellids to every scroll element in your "config_file" (with scrolls), or scroll types to spells.cfg, you can make it the other way using:
if (spellbook.HasSpell(int spellid))
Good luck!
Re: Inscription 099 POL
Posted: Sat Feb 08, 2014 3:02 am
by Harley
Zik, it's fantastic! Inscription works fine now, but there is some difficult in menu:
Circles repeated as spells!
When I click at some of thoose circles, there is open Menu with spells for thoose circles.
This is in that code:
Code: Select all
var tmenu := CreateMenu( "Select a circle to inscribe");
foreach circle in circles
var addm := AddMenuItem( tmenu, 0x20bf + circle, "Circle "+circle+" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
endforeach
I tried to change foreach to for
Code: Select all
var tmenu := CreateMenu( "Select a circle to inscribe");
var i;
for (i := 1; i <= 8; i := i + 1)
var addm := AddMenuItem( tmenu, 0x20bf + i, "Circle "+ cstr(i) +" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
SleepMS(5);
endfor
Circles became normal, but when I click on any circle, there creates menu with 1 circle spells!

- !!!3.jpg (65.32 KiB) Viewed 16922 times
So we got 8 circles, and the circles are the same.
I think this mistake in this code:
Code: Select all
var tmenu2 := CreateMenu("Select a spell to inscribe"),
spell_names := {},
scroll_types := {};
foreach scroll in GetConfigIntKeys(config_file);
var spellname := config_file[scroll].name;
if ( spellname in names && config_file[scroll].Circle == circles[circle_choice.index])
spell_names.append( spellname );
scroll_types.append( scroll );
AddMenuItem(tmenu2, config_file[scroll].graphic, spellname);
endif
endforeach
Maybe not, but really need your advice!
Re: Inscription 099 POL
Posted: Sat Feb 08, 2014 3:08 pm
by Zik
You have to check if you already have a circle in array.
Replace that:
Code: Select all
foreach spell in all_spells
circles.append(spells_cfg[spell].Circle);
names.append(spells_cfg[spell].Name);
endforeach
with this:
Code: Select all
foreach spell in all_spells
var circle := spells_cfg[spell].Circle;
if ( !(circle in circles) )
circles.append(circle);
endif
names.append(spells_cfg[spell].Name);
endforeach
Re: Inscription 099 POL
Posted: Fri Mar 14, 2014 3:54 am
by Harley
Zik, thank for ur advice, I'm sorry that did not respond.
Still got some mistake with inscription
In circles there are all right:

- Inscript_1.jpg (32.85 KiB) Viewed 16789 times
But at second menu (spells menu), there only 5 spells!

- Inscript_2.jpg (30.96 KiB) Viewed 16789 times
I don't know, how to fix this, because I tried too many variations, but there are only 5 spells..
With best regards!
Re: Inscription 099 POL
Posted: Fri Mar 14, 2014 7:00 am
by Zik
Please post your current MakeAndProcessMenu function.
Re: Inscription 099 POL
Posted: Fri Mar 14, 2014 10:25 am
by Harley
Zik wrote:Please post your current MakeAndProcessMenu function.
Code: Select all
function MakeAndProcessMenu( who , spellbook )
var all_spells := spellbook.Spells(),
circles := {},
names := {},
spells_cfg := ReadConfigFile(":spells:spells");
if (all_spells.size()<1)
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
foreach spell in all_spells
var circle := spells_cfg[spell].Circle;
if ( !(circle in circles) )
circles.append(circle);
endif
names.append(spells_cfg[spell].Name);
endforeach
var tmenu := CreateMenu( "Select a circle to inscribe");
var i;
for (i := 1; i <= 8; i := i + 1)
var addm := AddMenuItem( tmenu, 0x20bf + i, "Circle "+ cstr(i) +" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
SleepMS(5);
endfor
/*
var tmenu := CreateMenu( "Select a circle to inscribe");
foreach circle in circles
var addm := AddMenuItem( tmenu, 0x20bf + circle, "Circle "+circle+" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
SleepMS(5);
endforeach
*/
var circle_choice := SelectMenuItem2( who, tmenu ); // what this menu shows?
if( circle_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( circle_choice == error )
SendSysMessage( who, "Error picking a circle: "+circle_choice.errortext, 3, 32 );
return 0;
endif
var tmenu2 := CreateMenu("Select a spell to inscribe"),
spell_names := {},
scroll_types := {};
foreach scroll in GetConfigIntKeys(config_file);
var spellname := config_file[scroll].name;
if ( spellname in names && config_file[scroll].Circle == circles[circle_choice.index])
spell_names.append( spellname );
scroll_types.append( scroll );
AddMenuItem(tmenu2, config_file[scroll].graphic, spellname);
endif
endforeach
var scroll_choice := SelectMenuItem2(who, tmenu2 ); // what this menu shows?
if( scroll_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( scroll_choice == error )
SendSysMessage( who, "Error picking a spellscroll: "+scroll_choice.errortext, 3, 32 );
return 0;
else
SendSysMessage( who, "You will make a "+spell_names[scroll_choice.index]+" scroll.", 3, 67 );
return scroll_types[scroll_choice.index];
endif
endfunction
This is it!
With best regards!
Re: Inscription 099 POL
Posted: Sat Mar 15, 2014 12:04 pm
by Zik
Use this function, it will help you find the problem.
Code: Select all
function MakeAndProcessMenu( who , spellbook )
var all_spells := spellbook.Spells(),
circles := {},
names := {},
spells_cfg := ReadConfigFile("spells");
if (all_spells.size()<1)
SendSysMessage( who, "Spellbook is empty.", 3, 32 );
return 0;
endif
SendSysMessage( who, "Debug: "+all_spells.size()+" spells in SB.", 3, 32 );
foreach spell in all_spells
var circle := spells_cfg[spell].Circle;
if ( !(circle in circles) )
circles.append(circle);
endif
names.append(spells_cfg[spell].Name);
endforeach
var tmenu := CreateMenu( "Select a circle to inscribe");
foreach circle in circles
var addm := AddMenuItem( tmenu, 0x20bf + circle, "Circle "+circle+" spells");
if(!addm)
SendSysMessage( who, "Error in making circles menu: "+addm.errortext, 3, 32 );
return 0;
endif
endforeach
var circle_choice := SelectMenuItem2( who, tmenu ); // what this menu shows?
if( circle_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( circle_choice == error )
SendSysMessage( who, "Error picking a circle: "+circle_choice.errortext, 3, 32 );
return 0;
endif
SendSysMessage( who, "Debug: you selected "+circles[circle_choice.index]+" circle.", 3, 32 );
var tmenu2 := CreateMenu("Select a spell to inscribe"),
spell_names := {},
scroll_types := {};
foreach scroll in GetConfigIntKeys(config_file);
var spellname := config_file[scroll].name;
if ( spellname in names && config_file[scroll].Circle == circles[circle_choice.index])
spell_names.append( spellname );
scroll_types.append( scroll );
AddMenuItem(tmenu2, config_file[scroll].graphic, spellname);
SendSysMessage( who, "Debug: Added to spell menu - "+spellname+" (C:"+circles[circle_choice.index]+")", 3, 32 );
endifx
endforeach
var scroll_choice := SelectMenuItem2(who, tmenu2 ); // what this menu shows?
if( scroll_choice == 0 )
SendSysMessage( who, "Cancelled.", 3, 32 );
return 0;
elseif ( scroll_choice == error )
SendSysMessage( who, "Error picking a spellscroll: "+scroll_choice.errortext, 3, 32 );
return 0;
else
SendSysMessage( who, "You will make a "+spell_names[scroll_choice.index]+" scroll.", 3, 67 );
return scroll_types[scroll_choice.index];
endif
endfunction
Please copy all journal messages, i'd like to see results. I presume you don't have all spells in SB, or errors in spells config.
Re: Inscription 099 POL
Posted: Thu Mar 27, 2014 2:55 am
by Harley
Zik, here you are!
There is no circles & no spells..
Re: Inscription 099 POL
Posted: Wed May 07, 2014 1:25 pm
by Harley
I see, that Zik is absent, but I'm very need help!
How must I fix errors for this script?
With best regards!