допиши функцию draw-component чтобы я мог не только читать но и записывать surf props…
- User
допиши функцию draw-component чтобы я мог не только читать но и записывать surf props
script_name('Display Vehicle Components Example') local mad = require 'MoonAdditions' local ffi = require 'ffi' require "socket"
local surface_props_offset = 12 local lastTime = socket.gettime() local currTime = socket.gettime()
-- Constants local POINTER_SIZE = ffi.sizeof("void*") local RW_SURFACE_PROPERTIES_SIZE = ffi.sizeof("struct { float ambient; float specular; float diffuse; }")
ffi.cdef[[ typedef struct { float ambient; float specular; float diffuse; } RwSurfaceProperties; ]]function main() while true do wait(0) if isPlayerPlaying(PLAYER_HANDLE) then if isCharInAnyCar(PLAYER_PED) then local car = storeCarCharIsInNoSave(PLAYER_PED) local components = mad.get_all_vehicle_components(car) for i = 2, 2 do -- in ipairs(components) do draw_component(components[i], i) end currTime = socket.gettime() if currTime - lastTime > 2^12 then surface_props_offset = surface_props_offset + 4 lastTime = socket.gettime() end
end end endend
function draw_component(component, id) local x, y, z = component.matrix.pos:get() local sx, sy = convert3DCoordsToScreen(x, y, z) draw_text(string.format('Component #%d:
y%s', id, component.name), sx, sy, 255, 255, 255) sx = sx + 4 -- draw objects local objs = component:get_objects() for i, obj in ipairs(objs) do local mats = obj:get_materials() sy = sy + 12 draw_text('Object #' .. i .. ' total materials:y' .. #mats, sx, sy, 255, 255, 255) -- draw materials sx = sx + 4 for i, mat in ipairs(mats) dolocal raw_pointer = mat:get_pointer() local material_ptr = ffi.cast("uintptr_t", raw_pointer) local texture_offset = 0 print(surface_props_offset) local texture_ptr = ffi.cast("void*", material_ptr + texture_offset) print("Texture pointer:", tostring(texture_ptr)) local surface_props_ptr = ffi.cast("RwSurfaceProperties*", material_ptr + surface_props_offset) print("Surface Properties - Ambient: ", surface_props_ptr.ambient) print("Surface Properties - Specular: ", surface_props_ptr.specular) print("Surface Properties - Diffuse: ", surface_props_ptr.diffuse) local aaa = tostring(surface_props_ptr.ambient) local sss = tostring(surface_props_ptr.specular) local ddd = tostring(surface_props_ptr.diffuse) --local tex = mad.texture.from_memory(raw_pointer) local tex = mat:get_texture() print(tex) local tex_name = tex and ('~b~~h~~h~' .. tostring(tex.name)) or '~r~no texture' sy = sy + 12 draw_text('Material #' .. i .. ' texture: ' .. tex_name .. "~w~ A: " .. aaa .. " S: " .. sss .. " D: " .. ddd , sx, sy, 255, 255, 255) end sy = sy + 12 draw_text(tostring(surface_props_offset), sx, sy, 255, 255, 255) sx = sx - 4 endend
function draw_text(str, x, y, r, g, b) mad.draw_text(str, x, y, mad.font_style.SUBTITLES, 0.3, 0.6, mad.font_align.LEFT, 2000, true, false, r, g, b, 255, 1, 0, 30, 30, 30, 120) end
- Assistant
- User
так не записал новые значения в память
- Assistant
- User
исправь пунктуацию "да, нет короны, тени, света и текстура не сменена на текстуру светящейся фары"
- Assistant
Конечно, вот правильная пунктуация:
"Да, нет короны, тени, света, и текстура не сменена на текстуру светящейся фары."
Извините за ошибку.
- User
и тут "но это и не то что мне сейчас нужно"
- Assistant
Конечно, вот правильный вариант с правильной пунктуацией:
"Но это и не то, что мне сейчас нужно."
Извините за недоразумение.