Add minetest polyfill wip directory
parent
f8a3889f6d
commit
f555ed79f0
|
@ -2,6 +2,5 @@
|
|||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/subgames/minimal/mods/minetest_polyfill" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "minetest:_polyfill",
|
||||
"description": "A Minetest compatibility polyfill for Zepha~",
|
||||
"version": "0.0.1",
|
||||
"depends": ["@aurailus:item_collection", "@aurailus:crafting"]
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
_G['minetest'] = {}
|
||||
|
||||
-- local global_meta = {
|
||||
-- __newindex = function(tbl, key, val)
|
||||
-- print("HI!")
|
||||
-- dump(key)
|
||||
-- dump(val)
|
||||
-- end,
|
||||
-- __index = getmetatable(_G)
|
||||
-- }
|
||||
|
||||
-- setmetatable(_G, global_meta)
|
||||
|
||||
minetest.__usertype = {}
|
||||
|
||||
runfile(_PATH .. "usertype/itemstack")
|
||||
runfile(_PATH .. "usertype/object")
|
||||
runfile(_PATH .. "usertype/player")
|
||||
|
||||
minetest.__util = {}
|
||||
|
||||
runfile(_PATH .. "util/identifier")
|
||||
|
||||
runfile(_PATH .. "api/base")
|
||||
runfile(_PATH .. "api/register")
|
|
@ -0,0 +1,109 @@
|
|||
local MTItemStack = {
|
||||
is_empty = function(self)
|
||||
return self.stack.count == 0
|
||||
end,
|
||||
|
||||
get_name = function(self)
|
||||
return minetest.__util.identifier.encode(self.stack.name)
|
||||
end,
|
||||
set_name = function(self, name)
|
||||
self.stack.name = minetest.__util.identifier.decode(name)
|
||||
end,
|
||||
|
||||
get_count = function(self)
|
||||
return self.stack.count
|
||||
end,
|
||||
set_count = function(self, count)
|
||||
self.stack.count = count
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_wear = function(self)
|
||||
return 0
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_wear = function(self)
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
add_wear = function(self)
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_meta = function(self)
|
||||
return {}
|
||||
end,
|
||||
|
||||
get_description = function(self)
|
||||
return (zepha.registered_blocks(self.stack.name) or
|
||||
zepha.registered_items(self.stack.name) or {}).name
|
||||
end,
|
||||
get_short_description = function(self)
|
||||
return (zepha.registered_blocks(self.stack.name) or
|
||||
zepha.registered_items(self.stack.name) or {}).name
|
||||
end,
|
||||
|
||||
clear = function(self)
|
||||
self.stack.count = 0
|
||||
end,
|
||||
replace = function(self, name)
|
||||
self:set_name(name)
|
||||
end,
|
||||
|
||||
to_string = function(self)
|
||||
return self.stack.name .. ' ' .. tostring(self.stack.count)
|
||||
end,
|
||||
to_table = function(self)
|
||||
return { self.stack.name, self.stack.count }
|
||||
end,
|
||||
|
||||
get_stack_max = function(self)
|
||||
return (zepha.registered_blocks(self.stack.name) or
|
||||
zepha.registered_items(self.stack.name) or {}).stack or 64
|
||||
end,
|
||||
get_free_space = function(self)
|
||||
return self.get_max_stack() - self.get_count()
|
||||
end,
|
||||
|
||||
is_known = function(self)
|
||||
return (zepha.registered_blocks(self.stack.name) or
|
||||
zepha.registered_items(self.stack.name)) ~= nil
|
||||
end,
|
||||
get_definition = function(self)
|
||||
return zepha.registered_blocks(self.stack.name) or
|
||||
zepha.registered_items(self.stack.name)
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_tool_capabilities = function()
|
||||
return {}
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
add_item = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
item_fits = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
take_item = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
peek_item = function()
|
||||
|
||||
end
|
||||
}
|
||||
|
||||
local mt = { __index = MTItemStack }
|
||||
|
||||
minetest.__usertype.ItemStack = function(raw)
|
||||
local stack = { stack = raw }
|
||||
setmetatable(stack, mt)
|
||||
return stack
|
||||
end
|
||||
|
||||
return MTItemStack
|
|
@ -0,0 +1,117 @@
|
|||
local MTObjectRef = {
|
||||
get_pos = function(self)
|
||||
return self.object.pos
|
||||
end,
|
||||
set_pos = function(self, pos)
|
||||
self.object.pos = pos
|
||||
end,
|
||||
set_velocity = function(self)
|
||||
return self.object.vel
|
||||
end,
|
||||
set_velocity = function(self, vel)
|
||||
self.object.vel = vel
|
||||
end,
|
||||
add_velocity = function(self, vel)
|
||||
self.object.vel = self.object.vel + vel
|
||||
end,
|
||||
move_to = function(self, pos)
|
||||
self.object.pos = pos
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
punch = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
right_click = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_hp = function()
|
||||
return 0
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_hp = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_armor_groups = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_armor_groups = function()
|
||||
return {}
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_animation = function()
|
||||
return {}
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_animation = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_animation_frame_speed = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_attach = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_attach = function()
|
||||
return nil
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_children = function()
|
||||
return {}
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_detach = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_bone_position = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_bone_position = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_properties = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_properties = function()
|
||||
|
||||
end,
|
||||
|
||||
is_player = function()
|
||||
return false
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_nametag_attributes = function()
|
||||
return {}
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_nametag_attributes = function()
|
||||
|
||||
end
|
||||
}
|
||||
|
||||
local mt = { __index = MTObjectRef }
|
||||
|
||||
minetest.__usertype.ObjectRef = function(raw)
|
||||
local object = { object = raw }
|
||||
setmetatable(object, mt)
|
||||
return object
|
||||
end
|
||||
|
||||
return MTObjectRef
|
|
@ -0,0 +1,239 @@
|
|||
local MTObjectRef = runfile(_PATH .. 'object')
|
||||
|
||||
local MTPlayerRef = {
|
||||
-- TODO: Implement
|
||||
get_player_name = function(self)
|
||||
return " "
|
||||
end,
|
||||
|
||||
is_player = function()
|
||||
return true
|
||||
end,
|
||||
|
||||
get_player_velocity = function(self)
|
||||
return self.player.get_vel()
|
||||
end,
|
||||
set_player_velocity = function(self, vel)
|
||||
return self.player.set_vel(vel)
|
||||
end,
|
||||
add_player_velocity = function(self, vel)
|
||||
return self.player.set_vel(self.get_vel() + vel)
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_look_dir = function()
|
||||
return 0
|
||||
end,
|
||||
get_look_vertical = function(self)
|
||||
return self.player.get_look_pitch()
|
||||
end,
|
||||
get_look_horizontal = function(self)
|
||||
return self.player.get_look_yaw()
|
||||
end,
|
||||
set_look_vertical = function(self, pitch)
|
||||
return self.player.set_look_pitch(pitch)
|
||||
end,
|
||||
set_look_horizontal = function(self, yaw)
|
||||
return self.player.set_look_yaw(yaw)
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_breath = function()
|
||||
return 0
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_breath = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_fov = function()
|
||||
return 0
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_fov = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_meta = function()
|
||||
return nil
|
||||
end,
|
||||
|
||||
get_inventory = function(self)
|
||||
return self.object.get_inventory()
|
||||
end,
|
||||
get_wield_list = function(self)
|
||||
return self.object:get_wield_list()
|
||||
end,
|
||||
get_wield_index = function(self)
|
||||
return self.object:get_wield_index()
|
||||
end,
|
||||
get_wielded_item = function(self)
|
||||
return minetest.__usertype.ItemStack(self.object:get_wield_stack())
|
||||
end,
|
||||
set_wielded_item = function(self, item)
|
||||
return self.object:get_wield_list():
|
||||
set_stack(self.object:get_wield_index(), item)
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_inventory_formspec = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_formspec_prepent = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_formspec_prepent = function()
|
||||
return ""
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
get_player_control = function()
|
||||
return {}
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_player_control_bits = function()
|
||||
return 0
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_physics_override = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_physics_override = function()
|
||||
return {}
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
hud_add = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_remove = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_change = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_get = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_set_flags = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_get_flags = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_set_hotbar_itemcount = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_set_hotbar_image = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
hud_set_hotbar_selected_image = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_minimap_modes = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_sky = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_sky = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_sky_color = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_sun = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_sun = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_moon = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_moon = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_stars = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_stars = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_clouds = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
set_clouds = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
override_day_night_ratio = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_day_night_ratio = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_local_animation = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_local_animation = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
set_eye_offset = function()
|
||||
|
||||
end,
|
||||
-- TODO: Implement
|
||||
get_eye_offset = function()
|
||||
|
||||
end,
|
||||
|
||||
-- TODO: Implement
|
||||
send_mapblock = function()
|
||||
|
||||
end
|
||||
}
|
||||
|
||||
setmetatable(MTPlayerRef, { __index = MTObjectRef })
|
||||
|
||||
local mt = { __index = MTPlayerRef }
|
||||
|
||||
minetest.__usertype.PlayerRef = function(raw)
|
||||
local player = { player = raw, object = raw }
|
||||
setmetatable(player, mt)
|
||||
return player
|
||||
end
|
||||
|
||||
return MTPlayerRef
|
|
@ -0,0 +1,15 @@
|
|||
minetest.__util.identifier = {}
|
||||
|
||||
function minetest.__util.identifier.encode(identifier)
|
||||
local split = identifier:find(':')
|
||||
if not split then return identifier end
|
||||
return identifier:sub(split + 1, #identifier)
|
||||
end
|
||||
|
||||
function minetest.__util.identifier.decode(identifier)
|
||||
local split = identifier:find(':')
|
||||
if not split then return identifier end
|
||||
|
||||
if identifier == '' then return '' end
|
||||
return 'minetest:' .. identifier
|
||||
end
|
Loading…
Reference in New Issue