extend default class ?
Moderator: POL Developer
extend default class ?
It is possible to add a extended function (methods) to default POL obj classes ?
For example, add a method "getLevel" for characters, and use it like: who.getLevel() ?
I know it is possible for items through method scripts.
For example, add a method "getLevel" for characters, and use it like: who.getLevel() ?
I know it is possible for items through method scripts.
Re: extend default class ?
I dont think its possible now.
Re: extend default class ?
As far as i know currently method scripts only apply to items.
There was a discussion previously between core developers which suggested they might look into enabling methods for more class types, but at this stage i'd guess we're not likely to see anything until POL1.00
There was a discussion previously between core developers which suggested they might look into enabling methods for more class types, but at this stage i'd guess we're not likely to see anything until POL1.00
Re: extend default class ?
Mmmh
items/multis in itemdesc.cfg per objtype
NPC in npcdesc.cfg per template
Character generally in uoclient.cfg
What is/was under discussion is to have a place to define at one specific spot all "default" methods independent of the objtype/template. Currently you have to add the right MethodScript to each item definition/npctemplate. It's a bit of work but with a few includes you can easily define default behaviour with specific overrides. (I personally used this for the tooltip pkthook to create in a fast way without dozen of objtype checks default and specific texts)
02-03-2010 Turley:
Added: MethodScript support for mobiles
NPC: npcdesc.cfg MethodScript entry
Character: uoclient.cfg section "General" MethodScript entry
items/multis in itemdesc.cfg per objtype
NPC in npcdesc.cfg per template
Character generally in uoclient.cfg
What is/was under discussion is to have a place to define at one specific spot all "default" methods independent of the objtype/template. Currently you have to add the right MethodScript to each item definition/npctemplate. It's a bit of work but with a few includes you can easily define default behaviour with specific overrides. (I personally used this for the tooltip pkthook to create in a fast way without dozen of objtype checks default and specific texts)
Re: extend default class ?
Wow!Turley wrote: ↑Thu Jul 27, 2017 9:32 am Mmmh02-03-2010 Turley:
Added: MethodScript support for mobiles
NPC: npcdesc.cfg MethodScript entry
Character: uoclient.cfg section "General" MethodScript entry
items/multis in itemdesc.cfg per objtype
NPC in npcdesc.cfg per template
Character generally in uoclient.cfg
What is/was under discussion is to have a place to define at one specific spot all "default" methods independent of the objtype/template. Currently you have to add the right MethodScript to each item definition/npctemplate. It's a bit of work but with a few includes you can easily define default behaviour with specific overrides. (I personally used this for the tooltip pkthook to create in a fast way without dozen of objtype checks default and specific texts)
Thanks!
It will make the code much more easy and beauty
Re: extend default class ?
I think I remember a discussion from 2011.. heh!
I just remembered about this idea the other day and felt i should document it in case someone feels a coder itch.
We have a tree for how objects in POL are abstractions of other thingsSo what if we had a Methods.cfg file.Code: Select all
UObject Account PolCore() DataFileElement | | Guild Script Datastore +---------+--------+ | | Array Dictionary Datafile Character Item | | AuxConnection Error String NPC | | Struct +------------------+--------------+-----------+ | | | | Package Equipment Lockable Map Multi | | | Packet +---+----+ +----+--------+ +----+----+ | | | | | | Party Armor Weapon Door Container Boat House | BinaryFile +----+----+ | | Spellbook Corpse
Then if you have a corpse object in the script - you can call a method like corpse.MoveToJail();Code: Select all
Elem Corpse { MethodScript :pkg:xyz } Elem Container { MethodScript :pkg:abc }
Corpse's method script doesn't have this... so then the core goes to the next up, Container, its not there, so it goes up until the method is found. Lets pretend Item has it.
If the itemdesc.cfg methodscript has a matching function name - itll use that instead.. or could have an override like _method() for using core methods.
This would let scripts extend other things like Datafiles, Arrays, Dictionaries, etc.
Re: extend default class ?
Would be great if it works this way. I really would use method functions for all npcs and characters. One thing I miss from ServUO on POL is the override function from C#.
Methods is a simple way to act like overrides.
Methods is a simple way to act like overrides.
Re: extend default class ?
After I added the methodScript for characters on uoclient.cfg, every time I close POL it crashes and create a minidump.
Does anyone know of fix for that?
Does anyone know of fix for that?
- Attachments
-
- 20170801222138-0.dmp
- (49.56 KiB) Downloaded 270 times
Re: extend default class ?
Firstly are you running the most recent core?
The most recent patch fixed some major crash errors when it came to method scripts.
Secondly the method script crashes were related to core function scripts in method scripts which require user input e.g. target() or RequestInput() or SendInputGump().
What is your method trying to do?
The most recent patch fixed some major crash errors when it came to method scripts.
Secondly the method script crashes were related to core function scripts in method scripts which require user input e.g. target() or RequestInput() or SendInputGump().
What is your method trying to do?
Re: extend default class ?
Does it happen every time? Which core binaries are you using? Did you compile it yourself or downloaded from the boards?
Re: extend default class ?
Yes, it happens every time.
I'm using the latest POL version from github, compiled myself. I always try to be up to date with the last versions.
If I remove the methods for characters, it doesn't crash when the server shutdown.
The methods just have some exported functions to check PropEdits, I not even use the listed methods you said in my server, except for Target of course, but I'm not using it on the character methods script.
Except if I need to do something special for the character methods, it is not soo much different from any method script I have in my shard.
I'm using the latest POL version from github, compiled myself. I always try to be up to date with the last versions.
If I remove the methods for characters, it doesn't crash when the server shutdown.
The methods just have some exported functions to check PropEdits, I not even use the listed methods you said in my server, except for Target of course, but I'm not using it on the character methods script.
Except if I need to do something special for the character methods, it is not soo much different from any method script I have in my shard.
Code: Select all
use os;
use uo;
include "include/arrays";
program Install()
return 1;
endprogram
exported function GetLevel( who )
var chardata := GetObjProperty(who, "chardata");
var charlevel := chardata["level"];
if (charlevel == error || !charlevel)
SetLevel(who, 0);
charlevel := 0;
endif
return charlevel;
endfunction
exported function setLevel(who, level)
var chardata := GetObjProperty(who, "chardata");
chardata.level := level;
SetObjProperty(who, "chardata", chardata);
return 1;
endfunction
exported function isClass(who, class)
var chardata := GetObjProperty(who, "chardata");
if (Lower(chardata.classe) == Lower(class))
return 1;
endif
return 0;
endfunction
exported function SkillList(who)
var chardata := GetObjProperty(who, "chardata");
var skill_list := chardata.Skills;
if (!skill_list)
skill_list := array{};
endif
return skill_list;
endfunction
exported function GetExp(who)
var chardata := GetObjProperty(who, "chardata");
var exppoints := chardata["exppoints"];
if (exppoints == error || !exppoints)
SetExp(who, 0);
exppoints := 0;
endif
return exppoints;
endfunction
exported function SetExp(who, points)
var chardata := GetObjProperty(who, "chardata");
chardata["exppoints"] := points;
SetObjProperty(who, "chardata", chardata);
return 1;
endfunction
exported function GetPoints(who)
var chardata := GetObjProperty(who, "chardata");
var attpoints := chardata["attpoints"];
if (attpoints == error || !attpoints)
SetPoints(who, 0);
attpoints := 0;
endif
return attpoints;
endfunction
exported function SetPoints(who, points)
var chardata := GetObjProperty(who, "chardata");
chardata["attpoints"] := points;
SetObjProperty(who, "chardata", chardata);
return 1;
endfunction
Re: extend default class ?
Does it only happen when calling one of the functions or is it crashing when you boot the server?
-
- Distro Developer
- Posts: 2825
- Joined: Thu Feb 02, 2006 1:41 pm
- Location: San Antonio, Texas
- Contact:
Re: extend default class ?
He said it happens on shutdown of POL. According to his screen shot it looks like it save the world data then crashes.
Re: extend default class ?
Should be fixed now. Let me know if it still happens.