Thread Tools Display Modes
12-10-05, 10:24 AM   #1
TryToMod
A Kobold Labourer
Join Date: Dec 2005
Posts: 1
Problem with ScrollFrame

Hey.

I've got a very annoying problem..
Have tried to make a scrollbar/frame for a few days now... I can create the scrollframe, but not that it scroll data

I got 1 error
Code:
interface\AddOns\scrollFrame\scrollFrame.lua:17 attempt to index a nil value
Ok! - Something is wrong at line 17 in .lua.. That is
Code:
getglobal("MyModEntry"..line.."_Text"):SetText(MyModData[lineplusoffset]);
I've tried to move frames, etc, etc but nothing works

This is how the code looks like:

scrollFrame.lua
Code:
function MyMod_OnLoad()
   MyModData = {};
   for i=1,50 do
     MyModData[i] = "Test "..math.random(100);
   end
 end


function MyModScrollBar_Update()

   local line; -- 1 through 5 of our window to scroll
   local lineplusoffset; -- an index into our data calculated from the scroll offset
   FauxScrollFrame_Update(MyModScrollBar,50,5,16);
   for line=1,5 do
     lineplusoffset = line + FauxScrollFrame_GetOffset(MyModScrollBar);
     if lineplusoffset < 50 then
       getglobal("MyModEntry"..line.."_Text"):SetText(MyModData[lineplusoffset]);
       getglobal("MyModEntry"..line):Show();
     else
       getglobal("MyModEntry"..line):Hide();
     end
   end
 end
scrollFrame.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
	<Script file="scrollFrame.lua"/>
<Frame name="scrollbar" toplevel="true" parent="UIParent" frameStrata="DIALOG"
    hidden="false" enableMouse="true">

	<Size><AbsDimension x="300" y="600"/></Size>
	<Anchors><Anchor point="CENTER"/></Anchors>

<Frames>
<ScrollFrame name="MyModScrollBar" inherits="FauxScrollFrameTemplate">
   <Size>
     <AbsDimension x="30" y="80"/>
   </Size>
   <Anchors>
     <Anchor point="TOPRIGHT"/>
   </Anchors>
   <Scripts>
     <OnVerticalScroll>
       FauxScrollFrame_OnVerticalScroll(16, MyModScrollBar_Update);
     </OnVerticalScroll>
   </Scripts>
 </ScrollFrame>


 <Button name = "MyModEntryTemplate" virtual="true">
   <Size>
     <AbsDimension x="150" y="16" />
   </Size>
   <Layers>
     <Layer level="BORDER">
       <FontString name="$parent_Text" inherits="GameFontHighlight" wraponspaces="false"
               justifyH="LEFT" text="MyModEntry"/>
     </Layer>
   </Layers>
 </Button>
</Frames>

<Frames>
 <Button name="MyModEntry1" inherits="MyModEntryTemplate" text="Test">
   <Anchors>
     <Anchor point="TOPRIGHT" relativeTo="MyModScrollBar" relativePoint="TOPLEFT"/>
   </Anchors>
 </Button>
 <Button name="MyModEntry2" inherits="MyModEntryTemplate">
   <Anchors>
     <Anchor point="TOPLEFT" relativeTo="MyModEntry1" relativePoint="BOTTOMLEFT"/>
   </Anchors>
 </Button>
 <Button name="MyModEntry3" inherits="MyModEntryTemplate">
   <Anchors>
     <Anchor point="TOPLEFT" relativeTo="MyModEntry2" relativePoint="BOTTOMLEFT"/>
   </Anchors>
 </Button>
 <Button name="MyModEntry4" inherits="MyModEntryTemplate">
   <Anchors>
     <Anchor point="TOPLEFT" relativeTo="MyModEntry3" relativePoint="BOTTOMLEFT"/>
   </Anchors>
 </Button>
 <Button name="MyModEntry5" inherits="MyModEntryTemplate">
   <Anchors>
     <Anchor point="TOPLEFT" relativeTo="MyModEntry4" relativePoint="BOTTOMLEFT"/>
   </Anchors>
 </Button>


</Frames>
</Frame>

<Frame name="OnLoad">
	<Scripts>
		<OnLoad>
			MyMod_OnLoad();
		</OnLoad>
	</Scripts>
</Frame>

</Ui>
Please, I need help.. Im going nuts here

Last edited by TryToMod : 12-12-05 at 01:09 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem with ScrollFrame

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off