Iris2.de

Iris2-Forum
It is currently Wed Dec 02, 2020 12:24 am

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Fri Apr 24, 2009 1:03 am 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
An Error Will Blow Up My Mind...

Need Help With That Code!

I Registered A Listener, That Works, But I'm Trying To Set My Gumppic Width i looked in healthbar.lua and doing same thing but whatever i tried, it doesn't :shock: :shock:

Error: HotBar.lua line 85:
"attempt to call method 'GetCtrlByName' (a nil value)
....

The name Parameter Comes from Another function as you can see...

Help Help Need Help :)

Code:
-- Register Listeners.
RegisterListener("Mobile_UpdateHealth",   function (mobile, oldcur, oldmax, curvalue, maxvalue)
    UpdateHotBar(mobile)
end)

-- Created 24.04.2009 00:52:12, with GumpStudio & Iris2 Lua Export Plugin
-- Exported Iris2 GumpExporter ver 1.0.
local HotBarGump = {}
HotBarGump.dialogId = 5000011
HotBarGump.x = 0
HotBarGump.y = 0
HotBarGump.Data =
    "{ page 0 }" ..
    "{ gumppic 0 0 13200 hotbarpic }" ..
    "{ text 197 103 0 0 lblSlotTwo }" ..
    "{ text 246 103 0 1 lblSlotThree }" ..
    "{ text 294 103 0 2 lblSlotFour }" ..
    "{ text 342 103 0 3 lblSlotFive }" ..
    "{ text 393 103 0 4 lblSlotSiz }" ..
    "{ text 441 103 0 5 lblSlotSeven }" ..
    "{ text 487 103 0 6 lblSlotEight }" ..
    "{ text 568 103 0 7 lblSlotPrimaryAbility }" ..
    "{ text 615 103 0 8 lblSlotSecondaryAbility }" ..
    "{ gumppic 137 48 13201 imghits }" ..
    "{ text 347 40 1153 9 lblhits }" ..
    "{ gumppic 385 62 13203 imgStam }" ..
    "{ text 146 103 0 10 lblSlotOne }" ..
    "{ gumppic 137 62 13202 imgMana }" ..
    "{ text 221 54 1153 11 lblmana }" ..
    "{ text 473 54 1153 12 lblstam }" ..
    ""
HotBarGump.textline = {
   [0] = "2",
   [1] = "3",
   [2] = "4",
   [3] = "5",
   [4] = "6",
   [5] = "7",
   [6] = "8",
   [7] = "Q",
   [8] = "W",
   [9] = "67/128",
   [10] = "1",
   [11] = "67/128",
   [12] = "67/128",
}

kHealthBarFullWidth = 471

-- GumpParser( manualGump )

gHotBarGumps = {}

SetMacro("1", function() ShowHotBar(GetPlayerMobile()) end)

function ShowHotBar(mobile)
    if gNoRender then return end
    if mobile == nil then return end
    if (gHotBarGumps[mobile.serial]) then return end
    local dialog = GumpParser(HotBarGump, true)
    gHotBarGumps[mobile.serial] = dialog
    --AddFadeLines(mobile.stats.curHits)
    dialog.controls["lblhits"].gfx:SetText(mobile.stats.curHits .. "/" .. mobile.stats.maxHits)
    dialog.controls["lblmana"].gfx:SetText(mobile.stats.curMana.. "/" .. mobile.stats.maxMana)
    dialog.controls["lblstam"].gfx:SetText(mobile.stats.curStamina.. "/" .. mobile.stats.maxStamina)
    SetHealthBarImage(mobile, 0.5)
    AddFadeLines("I'm Invoking. Step ShowHotBar")
    --dialog.gfx:SetPos(0, 0)
end

function UpdateHotBar(mobile)
    local dialog = gHotBarGumps[mobile.serial] if (not dialog) then return end
    dialog.controls["lblhits"].gfx:SetText(mobile.stats.curHits .. "/" .. mobile.stats.maxHits)
    dialog.controls["lblmana"].gfx:SetText(mobile.stats.curMana.. "/" .. mobile.stats.maxMana)
    dialog.controls["lblstam"].gfx:SetText(mobile.stats.curStamina.. "/" .. mobile.stats.maxStamina)
    SetHealthBarImage(mobile, mobile.stats.curHits / mobile.stats.maxHits)
end

function SetHealthBarImage(mobile, x)
    HotBar_ChangeParams(mobile.serial, "imghits", {tiled=true,width=kHealthBarFullWidth * max(0,min(1,x))})
end

function HotBar_ChangeParams (serial, ctrlname, changearr)
   local dialog = gHotBarGumps[serial] if (not dialog) then return end
   local widget = dialog:GetCtrlByName(ctrlname) if (not widget) then return end
   widget:ChangeParams(changearr)
end


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 6:45 am 
Offline
iris2-developer
User avatar

Joined: Mon Aug 09, 2004 12:20 pm
Posts: 1431
Try to set

Code:
HotBarGump.bSupportsGuiSys2 = true


between
HotBarGump.y = 0
<--
HotBarGump.Data =
.

You can analyze an Array by printing out the whole data via:

Code:
print("  ",vardump(dialog))


I think you mixed guisystem1 code with guisystem2 code :-/. We have a new guisystem and an old one which is obsolete, but we haven't converted all clientside gumps yet.

Also the gfx you used for gumppic is not existent by me 13200, 13201, 13202, 13203.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 3:19 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
SiENcE wrote:
Try to set

Code:
HotBarGump.bSupportsGuiSys2 = true


between
HotBarGump.y = 0
<--
HotBarGump.Data =
.

You can analyze an Array by printing out the whole data via:

Code:
print("  ",vardump(dialog))


I think you mixed guisystem1 code with guisystem2 code :-/. We have a new guisystem and an old one which is obsolete, but we haven't converted all clientside gumps yet.

Also the gfx you used for gumppic is not existent by me 13200, 13201, 13202, 13203.


13200, 13201, 13202, 13203 are my new hotbur gump pics :)

I'll Try new Gui System i'm at university now i'll back to home and try thanks for reply.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 7:52 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
That Works But I Have another Problem,

I Must Change Text Font How can I Do It ?

I Tried
Code:
dialog.controls["lblhits"].gfx:SetFont(gFontDefs["Gump"].name)
dialog.controls["lblhits"]:SetFont(gFontDefs["Gump"].name)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 8:14 pm 
Offline
iris2-developer
User avatar

Joined: Mon Aug 09, 2004 12:20 pm
Posts: 1431
take a look at config_declarations.lua :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 8:21 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
i looked but there is some declarations only,

when i try to use

SetFont function it says (a nil value)

i tried to use:
.gfx:SetFont
:SetFont

but both of them gives me same error


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 9:46 pm 
Offline
iris2-developer
User avatar

Joined: Mon Aug 09, 2004 12:20 pm
Posts: 1431
If something in guisystem is nil, it's mostly the wrong guisystem.
think SetFont was only the old guisystem.


Last edited by SiENcE on Fri Apr 24, 2009 11:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 24, 2009 10:15 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
then i won't set the font hmm :) k


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 25, 2009 6:47 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
A Question Again;

Can't Show My HotBar When Player Log in To game.

I make my hotbar (gui.hotbar.lua) I Put it To lua/gui folder and tried:

Code:
RegisterListener("Hook_StartInGame", function ()
AddFadeLines("Started In game")
ShowHotBar()
AddFadeLines("Showing Hot Bar")
end)


It Writes "Showing Hot Bar" But Not Showing Bar. My ShowHotBar Function:

Code:
function ShowHotBar()
    if gNoRender then return end
    local mobile = GetPlayerMobile()
    if mobile == nil then return end
    if (gHotBarGumps[mobile.serial]) then return end
    local dialog = GumpParser(HotBarGump, true)
    gHotBarGumps[mobile.serial] = dialog
    dialog.mobile = mobile
    UpdateHotBar(mobile)
    local width,height = GetViewportSize()
    local posx = width - kHotBarWidth
    local posy = height - kHotBarHeight
    dialog:SetPos(posx, posy)
    AddFadeLines("Showing HotBar")
    dialog.on_mouse_left_down = function (self)
      self:BringToFront()
      if IsTargetModeActive() then
         CompleteTargetModeWithTargetMobile(self.mobile)
      else
         return
      end
   end
end


Help Please..


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 10:49 am 
Offline
iris2-developer
User avatar

Joined: Tue Apr 18, 2006 10:28 pm
Posts: 823
Location: Munich, Bavaria, Germany
try
InvokeLater(10*1000,function () ShowHotBar() end)

instead of

ShowHotBar()

directly.

Hook_StartInGame is triggered rather early,
GetPlayerMobile() might still return nil at this point.
best put a print in the
if mobile == nil then return end
line as well


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 1:46 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
another problem ghoulsblade,
when i put my lua script to gui folder it doesn't works

bu if i put my script to plugins folder, it works correctly :S What i'm doing wrong ?

Thats all of my script(gui.hotbar.lua):
Code:
-- Created 24.04.2009 00:52:12, with GumpStudio & Iris2 Lua Export Plugin
-- Exported Iris2 GumpExporter ver 1.0.
local HotBarGump = {}
HotBarGump.dialogId = 5000012
HotBarGump.x = 0
HotBarGump.y = 0
HotBarGump.bSupportsGuiSys2 = true
HotBarGump.Data =
    "{ page 0 }" ..
    "{ gumppic -1 0 13200 }" ..
    "{ button 588 78 20994 20994 1 0 0 btnPrimaryAbility }" ..
    "{ button 538 78 20992 20992 1 0 1 btnSecondaryAbility }" ..
    "{ button 457 78 21019 21019 1 0 2 btnSlotEight }" ..
    "{ button 409 78 21019 21019 1 0 3 btnSlotSeven }" ..
    "{ button 361 78 21019 21019 1 0 4 btnSlotSix }" ..
    "{ button 312 78 21019 21019 1 0 5 btnSlotFive }" ..
    "{ button 263 78 21019 21019 1 0 6 btnSlotFour }" ..
    "{ button 116 78 21019 21019 1 0 7 btnSlotThree }" ..
    "{ button 165 78 21019 21019 1 0 8 btnSlotTwo }" ..
    "{ button 214 78 21019 21019 1 0 9 btnSlotOne }" ..
    "{ text 243 102 0 0 lblSlotThree }" ..
    "{ text 292 102 0 1 lblSlotFour }" ..
    "{ text 341 102 0 2 lblSlotFive }" ..
    "{ text 390 102 0 3 lblSlotSix }" ..
    "{ text 438 102 0 4 lblSlotSeven }" ..
    "{ text 486 102 0 5 lblSlotEight }" ..
    "{ text 569 102 0 6 lblPrimaryAbility }" ..
    "{ gumppic 139 48 13201 imghits }" ..
    "{ text 347 44 1153 7 lblhits }" ..
    "{ gumppic 387 62 13203 imgstam }" ..
    "{ gumppic 139 62 13202 imgmana }" ..
    "{ text 221 58 0 8 lblmana }" ..
    "{ text 473 58 0 9 lblstam }" ..
    "{ text 148 102 0 10 lblSlotOne }" ..
    "{ text 616 102 0 11 lblSecondaryAbility }" ..
    "{ text 194 102 0 12 lblSlotTwo }" ..
    ""
HotBarGump.textline = {
   [0] = "3",
   [1] = "4",
   [2] = "5",
   [3] = "6",
   [4] = "7",
   [5] = "8",
   [6] = "Q",
   [7] = "67/128",
   [8] = "67/128",
   [9] = "67/128",
   [10] = "1",
   [11] = "W",
   [12] = "2",
}

kHotBarWidth = 750
kHotBarHeight = 127
kHealthBarFullWidth = 471
kManaBarFullWidth = 233
kStaminaBarFullWidth = 223

-- GumpParser( manualGump )

gHotBarGumps = {}

function ShowHotBar()
    if gNoRender then return end
    local mobile = GetPlayerMobile()
    if mobile == nil then
        print("Mobile is nil!")
        InvokeLater(5*1000, function () ShowHotBar() end)
        return
    end
    if (gHotBarGumps[mobile.serial]) then return end
    local dialog = GumpParser(HotBarGump, true)
    gHotBarGumps[mobile.serial] = dialog
    dialog.mobile = mobile
    UpdateHotBar(mobile)
    local width,height = GetViewportSize()
    local posx = width - kHotBarWidth
    local posy = height - kHotBarHeight
    dialog:SetPos(posx, posy)
    dialog.on_mouse_left_down = function (self)
      self:BringToFront()
      if IsTargetModeActive() then
         CompleteTargetModeWithTargetMobile(self.mobile)
      else
         return
      end
   end
    --AddFadeLines(mobile.stats.curHits)
    --AddFadeLines("I'm Invoking. Step ShowHotBar")
    --dialog.gfx:SetPos(0, 0)
end

function UpdateHotBar(mobile)
    local dialog = gHotBarGumps[mobile.serial] if (not dialog) then return end
    --dialog.controls["lblhits"]:SetFont(gFontDefs["Gump"].name)
    dialog.controls["lblhits"]:SetText(mobile.stats.curHits .. "/" .. mobile.stats.maxHits)
    dialog.controls["lblmana"]:SetText(mobile.stats.curMana.. "/" .. mobile.stats.maxMana)
    dialog.controls["lblstam"]:SetText(mobile.stats.curStamina.. "/" .. mobile.stats.maxStamina)
    SetHealthBarImage(mobile, mobile.stats.curHits / mobile.stats.maxHits)
    SetManaBarImage(mobile, mobile.stats.curMana / mobile.stats.maxMana)
    SetStaminaBarImage(mobile, mobile.stats.curStamina / mobile.stats.maxStamina)
end

function SetStaminaBarImage(mobile, x)
    HotBar_ChangeParams(mobile.serial, "imgstam" , {tiled=true,width=kStaminaBarFullWidth * max(0,min(1,x))})
end

function SetManaBarImage(mobile, x)
    HotBar_ChangeParams(mobile.serial, "imgmana" , {tiled=true,width=kManaBarFullWidth * max(0,min(1,x))})
end

function SetHealthBarImage(mobile, x)
    HotBar_ChangeParams(mobile.serial, "imghits", {tiled=true,width=kHealthBarFullWidth * max(0,min(1,x))})
end

function HotBar_ChangeParams (serial, ctrlname, changearr)
   local dialog = gHotBarGumps[serial] if (not dialog) then return end
   local widget = dialog:GetCtrlByName(ctrlname) if (not widget) then return end
   widget:ChangeParams(changearr)
end

-- Register Listeners
RegisterListener("Mobile_UpdateStats", function(mobile)
    if not (IsPlayerMobile(mobile)) then return end
    if not (GetPlayerMobile().serial == mobile.serial) then return end
    UpdateHotBar(mobile)
end)

RegisterListener("Hook_StartInGame", function ()
ShowHotBar()
end)


Thanks For Help


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 1:57 pm 
Offline
iris2-developer
User avatar

Joined: Mon Aug 09, 2004 12:20 pm
Posts: 1431
Plugins are loaded dynamically.

If you put your script into the gui folder, you have to specify a reference in gui.main.lua.

But you shouldn't do that, because you can get easily conflicts when updating.

Just put it into the Plugin Folder and everything is ok.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 2:00 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
got it, thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 5:31 pm 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
Another Error Will Make Me Crazy...!
I'm Trying To Add Weapon Abilities to my hot bar then i create a function

Code:
function UpdateWeaponAbilities(mobile)
    local dialog = gHotBarGumps[mobile.serial]
    if not (dialog) then print("#####NO DIALOG") InvokeLater(5*1000, function () UpdateWeaponAbilities(mobile) end) return end
    local PrimaryAbility,SecondaryAbility = GetWeaponSpecialsForMobile(GetPlayerMobile())
   local PrimaryAbilityName = glWeaponAbilities[PrimaryAbility] and glWeaponAbilities[PrimaryAbility].name or "?"
   local PrimaryAbilityIconId = glWeaponAbilities[PrimaryAbility].gumpicon or 0x5200
   local SecondaryAbilityName = glWeaponAbilities[SecondaryAbility] and glWeaponAbilities[SecondaryAbility].name or "?"
   local SecondaryAbilityIconId = glWeaponAbilities[SecondaryAbility].gumpicon or 0x5200
   local widget = dialog:GetCtrlByName("btnPrimaryAbility")
    if not widget then
        AddFadeLines("Primary: "..PrimaryAbilityIconId.." Secondary: "..SecondaryAbilityIconId)
    else
        local changearr = { gump_id = PrimaryAbilityIconId, gump_id_pressed = PrimaryAbilityIconId }
        print(vardump(changearr))
        widget:ChangeParams( changearr )
    end
end


But It Gives Me Error:
ChangeParams (a nil value)

My Gump Supports New Gui System; On The Other Hand This Function Works Correctly For Me In Another Function:

Code:
local widget = GetWidgetUnderMouse()
      if(IsSkillButton(widget)) then
          if not (IsWeaponAbility(widget)) then
              print(vardump(widget.params))
              widget:ChangeParams( { gump_id = 0x3394, gump_id_pressed = 0x3394 } )
           end
      end


Regards...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 9:48 am 
Offline
Power User
User avatar

Joined: Fri Apr 17, 2009 2:32 pm
Posts: 122
Sehlor wrote:
Another Error Will Make Me Crazy...!
I'm Trying To Add Weapon Abilities to my hot bar then i create a function

Code:
function UpdateWeaponAbilities(mobile)
    local dialog = gHotBarGumps[mobile.serial]
    if not (dialog) then print("#####NO DIALOG") InvokeLater(5*1000, function () UpdateWeaponAbilities(mobile) end) return end
    local PrimaryAbility,SecondaryAbility = GetWeaponSpecialsForMobile(GetPlayerMobile())
   local PrimaryAbilityName = glWeaponAbilities[PrimaryAbility] and glWeaponAbilities[PrimaryAbility].name or "?"
   local PrimaryAbilityIconId = glWeaponAbilities[PrimaryAbility].gumpicon or 0x5200
   local SecondaryAbilityName = glWeaponAbilities[SecondaryAbility] and glWeaponAbilities[SecondaryAbility].name or "?"
   local SecondaryAbilityIconId = glWeaponAbilities[SecondaryAbility].gumpicon or 0x5200
   local widget = dialog:GetCtrlByName("btnPrimaryAbility")
    if not widget then
        AddFadeLines("Primary: "..PrimaryAbilityIconId.." Secondary: "..SecondaryAbilityIconId)
    else
        local changearr = { gump_id = PrimaryAbilityIconId, gump_id_pressed = PrimaryAbilityIconId }
        print(vardump(changearr))
        widget:ChangeParams( changearr )
    end
end


But It Gives Me Error:
ChangeParams (a nil value)

My Gump Supports New Gui System; On The Other Hand This Function Works Correctly For Me In Another Function:

Code:
local widget = GetWidgetUnderMouse()
      if(IsSkillButton(widget)) then
          if not (IsWeaponAbility(widget)) then
              print(vardump(widget.params))
              widget:ChangeParams( { gump_id = 0x3394, gump_id_pressed = 0x3394 } )
           end
      end


Regards...


any solution :roll: ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group