Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2013-10-19, 19:06


Dorex

Rick






Wiek: 28
Na forum: 4997 dni
Posty: 113

Piwa: 2477

Respekt: 296,3
Respekt: 296,3Respekt: 296,3Respekt: 296,3

Mam problem z funkcj? getmetatable w tworzeniu skryptu za pomoc? klas.

Prosze o pomoc dodaje tak?e KOD:

Zapisywanie = false

Tabela = {}
Tabela_index = Tabela
Tabela.Zapis = 0

function Tabela:ParametrPojazd(model,x,y,z,PodTyp)
Pamiec = {}
Pamiec.model = model
Pamiec.PodTyp = PodTyp
Pamiec.x = x
Pamiec.y = y
Pamiec.z = z
Tabela.Zapis = Tabela.Zapis+1

setmetatable(Pamiec, Tabela)
self.__index = self

W = getmetatable(Tabela)

outputDebugString ("Create Code:"..W, 3, 112, 112, 112 )
outputDebugString ("Vehicle:"..model..", X:"..x..", Y:"..y..", Z:"..z..", Type:"..PodTyp, 3, 112, 112, 112 )
local TymczasowyPojazd = createVehicle ( model, x, y, z)
setElementData(TymczasowyPojazd,"Typ",PodTyp)
outputDebugString ("Wykonane Indeksy:"..Tabela.Zapis)
if Zapisywanie == true then
local time = getRealTime()
local tn=string.format("Operacje[%04d]/ %02d-%02d-%02d-%02d Operacja[Create Vehicle] .logs", time.year+1900, time.month, time.monthday, time.hour, time.minute) local fh=fileCreate("Pamiec Podreczna/"..tn) local ts=string.format("Operacja[Create Vehicle]:%02d,%02d,%02d,%02d",model,x,y,z,PodTyp,index) fileWrite(fh, ts.."\n") fileFlush(fh)
Tabela:Wynik()
end
end

Postaw piwo autorowi tego posta
 

 
Wysłany: 2013-10-19, 23:45


Brzysiek

Skrypter pralek






Wiek: 28
Na forum: 5339 dni
Posty: 488
Nick w MP: Brzysiek

Piwa: 1034

Respekt: 360
Respekt: 360Respekt: 360Respekt: 360Respekt: 360


Zapisywanie = false 

Tabela = {} 
Tabela.__index = Tabela -- zly zapis 
Tabela.Zapis = 0 

function Tabela:ParametrPojazd(model,x,y,z,PodTyp) 
Pamiec = {} 
Pamiec.model = model 
Pamiec.PodTyp = PodTyp 
Pamiec.x = x 
Pamiec.y = y 
Pamiec.z = z 
Tabela.Zapis = Tabela.Zapis+1 

setmetatable(Pamiec, Tabela) 
self.__index = self 

local x2 = tostring(x) -- dodalem tostringi, pamietaj, ze w lua wszystko zwraca rozne type zmiennych - nie mozesz wywolac typu int jako stringa, bo ci error wyskoczy. Dlatego uzywasz funkcji tostring aby uniknac takich przypadkow.
local y2 = tostring(y)
local z2 = tostring(z)
W = tostring(getmetatable(Tabela)) 

outputDebugString ("Create Code:"..W, 3, 112, 112, 112 ) 
outputDebugString ("Vehicle:"..tostring(model)..", X:"..x2..", Y:"..y2..", Z:"..z2..", Type:"..tostring(PodTyp), 3, 112, 112, 112 ) 
local TymczasowyPojazd = createVehicle ( model, x, y, z) 
setElementData(TymczasowyPojazd,"Typ",PodTyp) 
outputDebugString ("Wykonane Indeksy:"..Tabela.Zapis) 
if Zapisywanie == true then 
local time = getRealTime() 
local tn=string.format("Operacje[%04d]/ %02d-%02d-%02d-%02d Operacja[Create Vehicle] .logs", time.year+1900, time.month, time.monthday, time.hour, time.minute) 
local fh=fileCreate("Pamiec Podreczna/"..tn) 
local ts=string.format("Operacja[Create Vehicle]:%02d,%02d,%02d,%02d",model,x,y,z,PodTyp,index) 
fileWrite(fh, ts.."\n") 
fileFlush(fh) 
Tabela:Wynik() 
end 
end


Postaw piwo autorowi tego posta
 

 
Tagi: skrypt :: opp :: [getmetatable]
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku