Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lmaddox committed Dec 11, 2023
1 parent d5fd6e2 commit cb633ae
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 325 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
development/
development/
*.swp
295 changes: 4 additions & 291 deletions working_villagers/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,297 +374,6 @@ end
function working_villages.villager:set_wielded_item(item)
return self:set_wield_item_stack(item)
end
-- fake player
function working_villages.villager:get_pos()
return self.object:get_pos()
end
function working_villages.villager:set_pos(vel)
return self.object:set_pos(vel)
end
function working_villages.villager:get_velocity()
return self.object:get_velocity()
end
function working_villages.villager:add_velocity(vel)
return self.object:add_velocity(vel)
end

function working_villages.villager:move_to(...)
return self.object:move_to(...)
end
function working_villages.villager:punch(...)
return self.object:punch(...)
end
function working_villages.villager:right_click(clicker)
return self.object:right_click(clicker)
end

function working_villages.villager:get_wield_list()
return self.object:get_wield_list()
end

function working_villages.villager:get_armor_groups()
return self.object:get_armor_groups()
end
function working_villages.villager:set_armor_groups(groups)
return self.object:set_armor_groups(groups)
end

function working_villages.villager:get_animation()
return self.object:get_animation()
end

function working_villages.villager:set_animation_frame_speed(frame_speed)
return self.object:set_animation_frame_speed(frame_speed)
end
function working_villages.villager:get_attach()
return self.object:get_attach()
end
function working_villages.villager:set_attach(...)
return self.object:set_attach(...)
end
function working_villages.villager:get_children()
return self.object:get_children()
end
function working_villages.villager:set_detach()
return self.object:set_detach()
end

function working_villages.villager:get_bone_position()
return self.object:get_bone_position()
end
function working_villages.villager:set_bone_position(...)
return self.object:set_bone_position(...)
end

function working_villages.villager:set_properties(vel)
return self.object:set_properties(vel)
end

function working_villages.villager:get_nametag_attributes()
return self.object:get_nametag_attributes()
end
function working_villages.villager:set_nametag_attributes(vel)
return self.object:set_nametag_attributes(vel)
end

-- lua entity
function working_villages.villager:remove()
return self.object:remove()
end

function working_villages.villager:set_velocity(vel)
return self.object:set_velocity(vel)
end

function working_villages.villager:get_acceleration()
return self.object:get_acceleration()
end
function working_villages.villager:set_acceleration(acc)
return self.object:set_acceleration(acc)
end

function working_villages.villager:get_rotation()
return self.object:get_rotation()
end
function working_villages.villager:set_rotation(rot)
return self.object:set_rotation(rot)
end

function working_villages.villager:get_yaw()
return self.object:get_yaw()
end
function working_villages.villager:set_yaw(yaw)
return self.object:set_yaw(yaw)
end

function working_villages.villager:get_texture_mod()
return self.object:get_texture_mod()
end
function working_villages.villager:set_texture_mod(mod)
return self.object:set_texture_mod(mod)
end

function working_villages.villager:set_sprite(...)
return self.object:set_sprite(...)
end

function working_villages.villager:get_luaentity()
return self.object:get_luaentity()
end

-- player specific

function working_villages.villager:get_look_dir()
return self.object:get_look_dir()
end
function working_villages.villager:get_look_vertical()
return self.object:get_look_vertical()
end
function working_villages.villager:set_look_vertical(radians)
return self.object:set_look_vertical(radians)
end
function working_villages.villager:get_look_horizontal()
return self.object:get_look_horizontal()
end
function working_villages.villager:set_look_horizontal(radians)
return self.object:set_look_horizontal(radians)
end

function working_villages.villager:get_breath()
return self.object:get_breath()
end
function working_villages.villager:set_breath(value)
return self.object:set_breath(value)
end

function working_villages.villager:get_fov()
return self.object:get_fov()
end
function working_villages.villager:set_fov(fov, is_multiplier, transition_time)
return self.object:set_fov(fov, is_multiplier, transition_time)
end

function working_villages.villager:get_meta()
return self.object:get_meta()
end

function working_villages.villager:get_inventory_formspec()
return self.object:get_inventory_formspec()
end
function working_villages.villager:set_inventory_formspec(formspec)
return self.object:set_inventory_formspec(formspec)
end

function working_villages.villager:get_formspec_prepend(formspec)
return self.object:get_formspec_prepend(formspec)
end
function working_villages.villager:set_formspec_prepend(formspec)
return self.object:set_formspec_prepend(formspec)
end

function working_villages.villager:get_player_control()
return self.object:get_player_control()
end
function working_villages.villager:get_player_control_bits()
return self.object:get_player_control_bits()
end

function working_villages.villager:get_physic_override()
return self.object:get_physic_override()
end
function working_villages.villager:set_physic_override(override_table)
return self.object:set_physic_override(override_table)
end

function working_villages.villager:hud_add(hud_definition)
return self.object:hud_add(hud_definition)
end
function working_villages.villager:hud_remove(id)
return self.object:hud_remove(id)
end
function working_villages.villager:hud_change(id, stat, value)
return self.object:hud_change(id, stat, value)
end
function working_villages.villager:hud_get(id)
return self.object:hud_get(id)
end

function working_villages.villager:hud_get_flags()
return self.object:hud_get_flags()
end
function working_villages.villager:hud_set_flags(flags)
return self.object:hud_set_flags(flags)
end

function working_villages.villager:hud_get_hotbar_itemcount()
return self.object:hud_get_hotbar_itemcount()
end
function working_villages.villager:hud_set_hotbar_itemcount(count)
return self.object:hud_set_hotbar_itemcount(count)
end

function working_villages.villager:hud_get_hotbar_image()
return self.object:hud_get_hotbar_image()
end
function working_villages.villager:hud_set_hotbar_image(texturename)
return self.object:hud_set_hotbar_image(texturename)
end

function working_villages.villager:hud_get_hotbar_selected_image()
return self.object:hud_get_hotbar_selected_image()
end
function working_villages.villager:hud_set_hotbar_selected_image(texturename)
return self.object:hud_set_hotbar_selected_image(texturename)
end

function working_villages.villager:set_minimap_modes(modes, selected_mode)
return self.object:set_minimap_mdoes(mdoes, selected_mode)
end

function working_villages.villager:get_sky()
return self.object:get_sky()
end
function working_villages.villager:set_sky(sky_parameters)
return self.object:set_sky(sky_parameters)
end
function working_villages.villager:get_sky_color()
return self.object:get_sky_color()
end

function working_villages.villager:get_sun()
return self.object:get_sun()
end
function working_villages.villager:set_sun(sun_parameters)
return self.object:set_sun(sun_parameters)
end

function working_villages.villager:get_moon()
return self.object:get_moon()
end
function working_villages.villager:set_moon(moon_parameters)
return self.object:set_moon(moon_parameters)
end

function working_villages.villager:get_stars()
return self.object:get_stars()
end
function working_villages.villager:set_stars(stars_parameters)
return self.object:set_stars(stars_parameters)
end

function working_villages.villager:get_clouds()
return self.object:get_clouds()
end
function working_villages.villager:set_clouds(clouds_parameters)
return self.object:set_clouds(clouds_parameters)
end

function working_villages.villager:get_day_night_ratio()
return self.object:get_day_night_ratio()
end
function working_villages.villager:override_day_night_ratio(ratio)
return self.object:override_day_night_ratio(ratio)
end

function working_villages.villager:get_local_animation()
return self.object:get_local_animation()
end
function working_villages.villager:set_local_animation(...)
return self.object:set_local_animation(...)
end

function working_villages.villager:get_eye_offset()
return self.object:get_eye_offset()
end
function working_villages.villager:set_eye_offset(...)
return self.object:set_eye_offset(...)
end

function working_villages.villager:send_mapblock(blockpos)
return self.object:send_mapblock(blockpos)
end

--

-- working_villages.villager.is_named reports the villager is still named.
function working_villages.villager:is_named()
Expand Down Expand Up @@ -1298,6 +1007,8 @@ function working_villages.register_villager(product_name, def)

-- on_activate is a callback function that is called when the object is created or recreated.
local function on_activate(self, staticdata)
-- TODO villager lineage

-- parse the staticdata, and compose a inventory.
if staticdata == "" then
self.product_name = name
Expand Down Expand Up @@ -1486,6 +1197,8 @@ function working_villages.register_villager(product_name, def)

villager_def.is_fake_player = true

-- TODO optional villager/player lineage

minetest.register_entity(name, villager_def)

-- register villager egg.
Expand Down
31 changes: 2 additions & 29 deletions working_villagers/async_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -493,24 +493,6 @@ function working_villages.villager:handle_job_pos()
end
end



















-- data = {
-- appliance_id = <some_key>,
-- appliance_pos = {x=<x>, y=<y>, z=<z>}
Expand Down Expand Up @@ -548,8 +530,8 @@ function working_villages.villager:handle_appliance(data)
self:delay(100)
else
self:manipulate_appliance(appliance_pos, data)
--end
-- TODO check whether appliance is ready/inactive
-- this logic would be job-specific
self.job_data.manipulated_appliance[app_id] = true;
end
end
Expand Down Expand Up @@ -599,7 +581,7 @@ function working_villages.villager:manipulate_appliance(appliance_pos, data)
for _, operation in ipairs(operations) do
assert(operation ~= nil)
if operation.noop then
for _=0,operation.noop do coroutine.yield() end --wait 10 steps
for _=0,operation.noop do coroutine.yield() end -- some appliances take time to produce results
else
local app_list_name = operation.list
assert(app_list_name ~= nil)
Expand All @@ -609,9 +591,6 @@ function working_villages.villager:manipulate_appliance(appliance_pos, data)
local size = vil_inv:get_size("main");
for index = 1,size do
local stack = vil_inv:get_stack("main", index);
--if not stack:is_empty() then
-- log.error("Villager %s deciding whether to move %s from inventory to appliance's %s on position %s.", self.inventory_name, stack:get_name(), app_list_name, minetest.pos_to_string(appliance_pos))
--end
if (not stack:is_empty()) and (operation.put_func(self, stack, operation.data)) then
local appliance_meta = minetest.get_meta(appliance_pos);
local appliance_inv = appliance_meta:get_inventory();
Expand All @@ -626,9 +605,6 @@ function working_villages.villager:manipulate_appliance(appliance_pos, data)
appliance_inv:set_stack(app_list_name, i, new_stack);
vil_inv:set_stack("main", index, stack);
-- TODO check if success ?
--else
--leftover = stack:get_count()
--leftover = stack
if(target_def.on_metadata_inventory_put ~= nil) then -- active furnace doesn't have this
target_def.on_metadata_inventory_put(appliance_pos, app_list_name, index, new_stack, placer) -- index should be 0 ?
end
Expand Down Expand Up @@ -659,9 +635,6 @@ function working_villages.villager:manipulate_appliance(appliance_pos, data)
appliance_meta = minetest.get_meta(appliance_pos);
appliance_inv = appliance_meta:get_inventory();
local stack = appliance_inv:get_stack(app_list_name, index);
--if not stack:is_empty() then
-- log.error("Villager %s deciding whether to move %s to inventory from appliance's %s on position %s.", self.inventory_name, stack:get_name(), app_list_name, minetest.pos_to_string(appliance_pos))
--end
if (not stack:is_empty()) and (operation.take_func(self, stack, operation.data)) then
--if(target_def.allow_metadata_inventory_take ~= nil) and target_def.allow_metadata_inventory_take(furnace_pos, "fuel", index, stack, placer) then -- extra sanity check... I don't know why it doesn't work
local leftover = vil_inv:add_item("main", stack);
Expand Down
Loading

0 comments on commit cb633ae

Please sign in to comment.