Lua External

Материал из Oxygen Engine
Версия от 07:49, 20 апреля 2020; ForserX (обсуждение | вклад) (Новая страница: «== Support Namespace == * FFI * LFS * Marshal * LuaXML == New scripts methods/functions == === Math === <source lang="cpp"> a // b --> math.floor(a / b) a % b…»)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Support Namespace

  • FFI
  • LFS
  • Marshal
  • LuaXML

New scripts methods/functions

Math

a // b  --> math.floor(a / b)
a % b   --> math.mod

Bit32 namespace

bit.tobit(x)          --// normalize number to the numeric range of
                      --// bit operations (all bit ops use this implicitly)
bit.tohex(x[,n])      --// convert x to hex with n digits (default 8)
bit.bnot(x)           --// bitwise not of x
bit.band(x1[,x2...])  --// bitwise and of x1, x2, ...
bit.bor(x1[,x2...])   --// bitwise or of x1, x2, ...
bit.bxor(x1[,x2...])  --// bitwise xor of x1, x2, ...
bit.lshift(x, n)      --// left-shift of x by n bits
bit.rshift(x, n)      --// logical right-shift of x by n bits
bit.arshift(x, n)     --// arithmetic right-shift of x by n bits
bit.rol(x, n)         --// left-rotate of x by n bits
bit.ror(x, n)         --// right-rotate of x by n bits
bit.bswap(x)          --// byte-swap of x (little-endian <-> big-endian)
~ a     --> bit.bnot(a)
a & b   --> bit.band(a, b)
a | b   --> bit.bor(a, b)
a ~ b   --> bit.bxor(a, b)
a << b  --> bit.lshift(a, b)
a >> b  --> bit.rshift(a, b)

New functions to vanilla namespaces

--// Global Namespace Lua
debuggerTrigger() --// DebugBreak for VS
crashGame()	--// Crash game
to_log(string) --// Write message to xray-log

--// CMainMenu
CUIMainMenu.GetEngineBuild() --// Return engine build
CUIMainMenu.GetEngineBuildDate() --// Return engine build in format dd.mm.YY

--// CUITrackBar
CUITrackBar.SetIValue(int) --// Set current int value  
CUITrackBar.SetFValue(float) --// Set current float value 

--// CUIListBox
CUIListBox.GetItemHeight() --// Return item height from xml tag item_height
CUIListBox.SetSelectedIndex(int) --// Set current index to CUIListBox element

--// CHud
get_hud():ShowPdaMenu() --// Opportunity to turn on the PDA using 

--// ini_file
ini_file(string name, boolean read_only) --// Constructor for create/open ini_file in write mode
ini_file.iterate_sections(ini_file pself, functor<void> functor) --// The enumeration of all sections with a function call
ini_file.w_string(string section, string line, string value) --// Write string value for line in section
ini_file.remove_line(string section, string line) --// Remove line in section

--// CScriptXmlInit
CScriptXmlInit.NodeExists(path, idx) --// Checking exists node. Returns type: bool.

--// CActor
db.actor:iterate_belt(func, npc) --// Iterate items on belt using 
db.actor:set_actor_name(str) --// Set new name to Actor

ab.actor.thirst = float --// Actor thirst 
ab.actor.alcohol = float --// Actor alcohol

callback:Hit(lua_game_object(), float, vector, object, number) --// Binder.Callback: Actor got hit

--// Alife
alife():object(int id):get_trader().character_name = string --// Set Trade name for current object
alife():get_children(se_obj) --// Returns table of ids

--// Game
game.show_minimap(bool) --// Disable/Enable CZoneMap.
game.get_season() --// Returns current season. 
game.set_season(string) --// Set season by name.

--// CArtefact
CArtefact.can_spawn_zone = bool
CArtefact.health_restore_speed = float
CArtefact.radiation_restore_speed = float
CArtefact.satiety_restore_speed = float
CArtefact.power_restore_speed = float
CArtefact.bleeding_restore_speed = float
CArtefact.additional_inventory_weight = float

--// CLevel
level.u_event_gen(net_packet&, number, number) --// Generation Event to CGameObject
level.u_event_send(NET_Packet& P) --// Send event to xrServer
level.send(net_packet&, boolean, boolean, boolean, boolean)  --// Send event to xrServer
level.get_target_obj() --// Returns the object the actor is looking at.
level.get_target_dist() --// Returns the distantion to object the actor is looking at.
level.get_target_element()
level.get_view_entity()
level.set_view_entity(game_object*)
level.spawn_item(string, vector, number, number, boolean) --// Spawn item to Actor
level.get_active_cam()	--// Returns active actor cam
level.set_active_cam(number) --// Setter active actor cam
level.get_start_time()	--// Returns start game time
level.valid_vertex(number) --// Returns true/false. Check validation level-vertex
level.iterate_online_objects(functor) --// Iterator for online object and call functor to object.

--// RayTracer
--// rq_result
rq_result.object --// Returns object
rq_result.range --// Returns range
rq_result.element --// Returns rq_target element

--// rq_target
rq_target().targets:rqtNone --// Non Empty
rq_target().targets:rqtObject --// Object 
rq_target().targets:rqtStatic
rq_target().targets:rqtShape
rq_target().targets:rqtObstacle
rq_target().targets:rqtBoth
rq_target().targets:rqtDyn --// Dynamic object

--// ray_pick
ray_pick.ray_pick() --// Cunstruct raytracer object
ray_pick.query() --// Run raytracer

ray_pick.set_direction(FVector) --// Set direction 
ray_pick.set_range(float) --// Set range 
ray_pick.set_flags(rq_target) --// Set flags
ray_pick.set_ignore_object(CSriptGameObject) --// Set ignore object

ray_pick.get_result() --// Get rq_result value 
ray_pick.get_object() --// Get object 
ray_pick.get_distance() --// Get distance to object 
ray_pick.get_element() --// Get element

// CLevelGraph
level.CLevelGraph() --// Construct
level.CLevelGraph.level_id --// Current level id
level.CLevelGraph.vertices_count --// Vertices count for current level

--// CGameTask
CGameTask.get_type() --// Returned task type. (storyline or additional)

--// CPhrase
CPhrase.SetText(string) --// Set text for current phrase.
CPhrase.GetText() --// Returned text.

--// CPhraseDialog
CPhraseDialog.GetPhrase(string id) --// Returned CPhrase. 

--// CHolderCustom
holder.SetParamFv2(int, FVector2) --// Set params to holder object. Id and x & y.

LuaXML (Example)

--// XML Script
xml.xr_load(string) --// Load XML file. Returns table. (X-Ray FS)
xml.load(string) --// Load XML file. Returns table.
xml.eval(string) --// Load XML tags on string. Returns table.
xml.new(string) --// Create XML doc. String - Head tag. Returns table.
xml.save(string xml, string path) --// Save new XML doc.

--// table
xml:append(string)[id] = value --// Add new tag to current pos(id) into XML doc
xml:find(string) --// Find current tag on xml. Returns table.
xml:tag(string new_name) --// Set/Get current tag. Returns table.
xml:tag(table[, string]) --// Set/Get current tag. Returns table.
xml:str(table/string) --// Transform var to XML object. Returns an XML string in case of success or nil.

Marshal

marshal.encode(v[, constants])   --// serializes a value to a byte stream. Returns string.
marshal.decode(s[, constants])   --// deserializes a byte stream to a value. Returns table.
marshal.clone(orig[, constants]) --// deep clone a value (deep for tables and functions). Returns table.