- Joined
- Apr 8, 2009
- Messages
- 21
Hey guys, I'm making a very simple system to increase a hero's attributes using stat points (you gain some per level up), anyway, I can get the main menu to fire and it loads up, however when I select a button the event doesn't even fire.
I've got a udg_groupHeroes (unit, array) that stores the hero that each player can pick (which happens in another function) so that's where it gets all of that extra information. Even if the StatsAdd() function doesn't work, the Game - Display to ... function should still show something but I have no idea what's going on. AddHero<stat> is just another function I wrote to simplify adding stats. Any ideas why nothing is showing?
-
StatsMenu
- Events
- Conditions
-
Actions
- Custom script: call StatsMenu()
- Game - Display to (All players) the text: StatsMenu()
-
StatsAdd
-
Events
- Dialog - A dialog button is clicked for dialogStats
- Conditions
-
Actions
- Game - Display to (All players) for 30.00 seconds the text: You clicked somethi...
- Custom script: call StatsAdd()
- Game - Display to (All players) the text: StatsAdd was called!
-
Events
JASS:
function StatsMenu takes nothing returns boolean
local player p = GetTriggerPlayer()
local unit u = udg_groupHeroes[GetPlayerId(p)]
//Simple to check if the player actually owns a unit
if u == null then
return false
endif
//Create the Dialog
set udg_dialogStats = DialogCreate()
//Level %u |cffffff00%s|r
call DialogSetMessage(udg_dialogStats,GetUnitName(u) + " - Level |cffff8000" + I2S(GetHeroLevel(u)) + "|r|nSkill Points: " + I2S(GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_USED)))
set udg_dialogStatsStr = DialogAddButton(udg_dialogStats, "|cffff8080Power (" + I2S(GetHeroStr(u,false)) + ")|r", 49)
set udg_dialogStatsAgi = DialogAddButton(udg_dialogStats, "|cff80ff00Dexterity (" + I2S(GetHeroAgi(u,false)) + ")|r", 50)
set udg_dialogStatsInt = DialogAddButton(udg_dialogStats, "|cff80ffffEssence (" + I2S(GetHeroInt(u,false)) + ")|r", 51)
set udg_dialogStatsCancel = DialogAddButton(udg_dialogStats, "Cancel", 27)
call DialogDisplay(p, udg_dialogStats, true)
return true
endfunction
JASS:
function StatsAdd takes nothing returns boolean
local button b = GetClickedButton()
local player p = GetTriggerPlayer()
local unit u = udg_groupHeroes[GetPlayerId(p)]
//Simple to check if the player actually owns a unit
if u == null then
return false
endif
//Gives the user a chance to leave the window without spending any points
if b == udg_dialogStatsCancel then
return false
endif
//Adds points to Strength
if b == udg_dialogStatsStr then
call AddHeroStr(u, 1)
endif
if b == udg_dialogStatsAgi then
call AddHeroAgi(u, 1)
endif
if b == udg_dialogStatsInt then
call AddHeroInt(u, 1)
endif
return true
endfunction
I've got a udg_groupHeroes (unit, array) that stores the hero that each player can pick (which happens in another function) so that's where it gets all of that extra information. Even if the StatsAdd() function doesn't work, the Game - Display to ... function should still show something but I have no idea what's going on. AddHero<stat> is just another function I wrote to simplify adding stats. Any ideas why nothing is showing?