PDA

View Full Version : Extension help



ProfMarks
June 19th, 2010, 20:28
I have successfully built an extension that uses the vehicle template and adds a desktop icon to call up the custom window. I have been able to fight through all the problems with the exception of one, and I'd appreciate any insight the experienced coders could lend.

At first test, everything works great. However, on the main tab, where a vehicles description resides, I'm encountering a small problem.

When adding a new item, the default empty position text displays, I can click on it and edit the test as desired. I can close down the window, bring it back up and do the same. However, if I leave the campaign and return, any items entered previously do not allow me to enter new text into the description box and the default empty position text is gone.

If I previously entered information, I can edit it using the edit text from the menu command, but what I'm faced with is if someone doesn't enter something in the description text field during the current session, they will be locked out from doing so later on.

Thanks ahead of time.

Zeus
June 20th, 2010, 01:02
Hey ProfMarks, its hard to say exactly what the problem is without seeing the source for your extension. Can you post up the windowclass defintion and any associated LUA scripts and well see what we can do.

From the description you have given it might be a database node ownership issue, assuming this is a client accessible window.

ProfMarks
June 20th, 2010, 17:50
Thanks for the help offers:

Description window class:

<windowclass name="hq_description">
<sheetdata>
<!-- DESCRIPTION
-->
<formattedtextfield name="text">
<anchored>
<top>
<anchor>top</anchor>
<offset>5</offset>
</top>
<left>
<anchor>left</anchor>
</left>
<right>
<anchor>right</anchor>
</right>
</anchored>
<font>
<normal>chatfont</normal>
<bold>narratorfont</bold>
<italic>chatitalicfont</italic>
<bolditalic>chatbolditalicfont</bolditalic>
<title>defaultstringcontrol</title>
</font>
<linkicon>
<link>button_openwindow</link>
<emptylink>button_emptytarget</emptylink>
</linkicon>
<selectioncolor>#FFD296</selectioncolor>
<footer>footer_narrow</footer>
<empty>Click to enter description</empty>
</formattedtextfield>
</sheetdata>
</windowclass>


Main window class:

<windowclass name="hq">
<frame>npcsheet</frame>
<sharable/>
<placement>
<size>
<width>398</width>
<height>509</height>
</size>
</placement>
<sizelimits>
<dynamic/>
</sizelimits>
<minimize>minimized_npc</minimize>
<sharable/>
<tooltip>
<field>name</field>
</tooltip>
<sheetdata>
<!-- NAME
-->
<genericcontrol name="nameframe">
<bounds>38,15,-35,45</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
<windowopencontrol>
<anchored>
<to>nameframe</to>
<position>insidetopleft</position>
<offset>13,12</offset>
<size>
<width>20</width>
<height>20</height>
</size>
</anchored>
<icon>
<normal>button_openwindow</normal>
<pressed>button_emptytarget</pressed>
</icon>
<class>hq</class>
<description>
<field>name</field>
</description>
</windowopencontrol>
<stringfield name="name">
<anchored>
<top>
<parent>nameframe</parent>
<anchor>top</anchor>
<offset>13</offset>
</top>
<left>
<parent>nameframe</parent>
<anchor>left</anchor>
<offset>35</offset>
</left>
<right>
<parent>nameframe</parent>
<anchor>right</anchor>
<offset>-25</offset>
</right>
</anchored>
<empty>« New Headquarters »</empty>
<font>sheettext</font>
</stringfield>
<genericcontrol name="hostility">
<bounds>-66,27,20,20</bounds>
<icon>indicator_ctffneutral</icon>
<script> datanode = nil; function update() if datanode.getValue() == 1 then setIcon("indicator_ctfffoe"); elseif datanode.getValue() == 2 then setIcon("indicator_ctfffriend"); else setIcon("indicator_ctffneutral"); end end function onClickDown(button, x, y) if User.isHost() then if datanode.getValue() < 2 then datanode.setValue(datanode.getValue()+1); else datanode.setValue(0); end end end function onInit() datanode = window.getDatabaseNode().createChild(getName(), "number"); datanode.onUpdate = update; update(); end </script>
</genericcontrol>
<tokenfield name="token">
<bounds>13,25,25,25</bounds>
<empty>indicator_emptytoken</empty>
</tokenfield>
<genericcontrol name="tabcontentframe">
<bounds>25,60,-25,-25</bounds>
<frame>
<name>sheetgroup</name>
<offset>0,1,0,0</offset>
</frame>
</genericcontrol>
<!-- SUBWINDOWS
-->
<subwindow name="description">
<anchored>
<to>tabcontentframe</to>
<position>over</position>
<offset>-15,-7</offset>
</anchored>
<class>hq_description</class>
</subwindow>
<subwindow name="combat">
<anchored>
<to>tabcontentframe</to>
<position>over</position>
<offset>-15,-7</offset>
</anchored>
<class>hq_combat</class>
</subwindow>
<scrollercontrol name="description_scroller">
<bounds>-79,-50,45,27</bounds>
<target>description</target>
<button>
<normal>button_scroller</normal>
<pressed>button_scroller_down</pressed>
</button>
<invisible/>
</scrollercontrol>
<scrollercontrol name="combat_scroller">
<bounds>-79,-50,45,27</bounds>
<target>combat</target>
<button>
<normal>button_scroller</normal>
<pressed>button_scroller_down</pressed>
</button>
<invisible/>
</scrollercontrol>
<scrollercontrol name="other_scroller">
<bounds>-79,-50,45,27</bounds>
<target>other</target>
<button>
<normal>button_scroller</normal>
<pressed>button_scroller_down</pressed>
</button>
<invisible/>
</scrollercontrol>
<tabcontrol name="tabs">
<bounds>-22,50,18,150</bounds>
<tab>
<icon>tab_combat</icon>
<subwindow>combat</subwindow>
<scroller>combat_scroller</scroller>
</tab>
<tab>
<icon>tab_main</icon>
<subwindow>description</subwindow>
<scroller>description_scroller</scroller>
</tab>
<activate>1</activate>
</tabcontrol>
</sheetdata>
</windowclass>

ProfMarks
June 20th, 2010, 17:50
and the lua:

function onDrop(x,y,dragdata)
if dragdata.isType("hq") then
dropnode = dragdata.getDatabaseNode();
return nil;
elseif dragdata.isType("shortcut") then
local class = dragdata.getShortcutData();
if class == "hq" then
dropnode = dragdata.getDatabaseNode();
return nil;
end
end
return false;
end

function copyhq(target)
local newnode = target.getDatabaseNode();
local oldnode = dropnode;
if dropnode then
dropnode = nil;
else
return
end
--fields
newnode.createChild("name","string").setValue(oldnode.createChild("name","string").getValue());
newnode.createChild("hostility","number").setValue(oldnode.createChild("hostility").getValue());
newnode.createChild("token","token").setValue(oldnode.createChild("token").getValue());
newnode.createChild("size","string").setValue(oldnode.createChild("size").getValue());
newnode.createChild("cost","string").setValue(oldnode.createChild("cost").getValue());
newnode.createChild("condition","string").setValue(oldnode.createChild("condition").getValue());
newnode.createChild("location","string").setValue(oldnode.createChild("location").getValue());
newnode.createChild("rooms","string").setValue(oldnode.createChild("rooms").getValue());
newnode.createChild("roomlist","string").setValue(oldnode.createChild("roomlist").getValue());
newnode.createChild("features","string").setValue(oldnode.createChild("features").getValue());
newnode.createChild("token","token").setValue(oldnode.createChild("token","token").getValue());
-- attacks

end



function onSortCompare(w1, w2)
return w1.name.getValue() > w2.name.getValue();
end

function onFilter(w)
local f = string.lower(window.filter.getValue());

if f == "" then
return true;
end

if string.find(string.lower(w.name.getValue()), f, 0, true) then
return true;
end

return false;
end

Zeus
June 21st, 2010, 19:05
OK, given the forums have mashed the formatting, this is probably going to be easier to do if you attach your extension to a post as an attachment. I can then download it and take a look.

BTW. I noticed a few whitespaces in the middle of variable names like old node or ol dnode instead of oldnode, I assume this if the posts formatting thats done that but thought I should check just in case.

If you can't attach the extension, let me know and I'll PM you my email address and you can forward it that way.