What's new

Skrypty & Kody Wy?wietlenie tekstu

Czopeq

Advanced User
Joined
Jun 29, 2015
Messages
191
Reaction score
6
Hello, mam problem z wprowadzeniem tekstu do ramki, chc? ?eby wy?wietla?o item przez podane Id jednak wywala mi ca?y czas b??dy w konsoli.
[LUA]Tabela = {

["jeden"] = { storage = 1001,count = 10, item1 = 1740},

["dwa"] = { storage = 1002,count = 15, item1 = 1741},

["trzy"] = { storage = 1003,count = 30, item1 = 1742}

}


<talkaction words="/dialog" event="buffer">
local param = string.lower(param)
local str = ""
str = str .. "Tekst :\n\n"
for k, v in pairsByKeys(Tabela) do
local stor = getPlayerStorageValue(cid, v.storage)
str = str..k.. " " ..getItemNameById(v.item1).." = ".. ("["..(stor).."/"..v.count.."]") .."\n"
end
str = str .. ""
return doShowTextDialog(cid, 8983, str)

</talkaction>
[/LUA]

Bez ..getItemNameById(v.item1).. niema ?adnych b??d?w.. wy?wietla "stor" i "count".
 

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Odp: Wy?wietlenie tekstu

Co za b??d? Gdzie reszta kodu?
 

Czopeq

Advanced User
Joined
Jun 29, 2015
Messages
191
Reaction score
6
Odp: Wy?wietlenie tekstu

[LUA] function pairsByKeys(t, f)

local a = {}

for n in pairs(t) do table.insert(a, n) end

table.sort(a, f)

local i = 0

local iter = function ()

i = i + 1

if a == nil then return nil

else return a, t[a]

end

end

return iter

end[/LUA]

Code:
[26/09/2017 23:14:56] [Error - TalkAction Interface] 
[26/09/2017 23:14:56] buffer
[26/09/2017 23:14:56] Description: 
[26/09/2017 23:14:56] [string "local Tabela = {..."]:18: ')' expected near ','

[26/09/2017 23:14:56] [Error - TalkAction Interface] 
[26/09/2017 23:14:56] buffer
[26/09/2017 23:14:56] Description: 
[26/09/2017 23:14:56] [string "loadBuffer"]:13: attempt to call global 'pairsByKeys' (a nil value)

---------- Tre?? dodana o 23:21 ----------

Og?lnie to sobie przerabiam tego mod, simple_task:
http://www.tibiaking.com/forum/forums/topic/12151-simple-task-30/

Sam mod dzia?a dobrze, ale jak go przerabiam na co? innego to lipa.

---------- Tre?? dodana o 23:24 ----------

Ca?y kod:
http://wklej.org/id/3260570/
 

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Odp: Wy?wietlenie tekstu

Nie u?ywaj w configu zmiennych lokalnych.
 

Czopeq

Advanced User
Joined
Jun 29, 2015
Messages
191
Reaction score
6
Odp: Wy?wietlenie tekstu

Dzia?a dzi?ki :D
Tak btw... to b??d kt?ry zrobi?em to to, ?e da?em local Tabela? ;-;
 

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Odp: Wy?wietlenie tekstu

Tak, tylko je?li chodzi o config musz? by? zmienne globalne.
Wsz?dzie indziej mo?esz u?ywa? obydw?ch. Pami?taj tylko, ?e wa?niejsza b?dzie zmienna lokalna gdy np. dasz 2 takie same w skrypcie.
 
Top