Difference between revisions of "MT-replace-deprecated.sh"

From Minetest Developer Wiki
Jump to navigation Jump to search
(Created page with "This is a shell script for finding and replacing most deprecated function calls of mod code from old Minetest versions (0.4.x) to update them to Minetest 5.0.0. See also: htt...")
 
Tag: New redirect
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This is a shell script for finding and replacing most deprecated function calls of mod code from old Minetest versions (0.4.x) to update them to Minetest 5.0.0.
+
#REDIRECT [[Modding_Tips#Deprecated_function_calls]]
 
 
See also: https://forum.minetest.net/viewtopic.php?f=18&t=20403
 
 
 
<pre>
 
#!/bin/bash
 
# License: CC0
 
 
 
# How to use:
 
# 1) Open the terminal in the target mod directory
 
# 2) Call the script
 
 
 
files=$(find . -name "*.lua")
 
 
 
ref_call()
 
{
 
sed -i "s/:$1(/:$2(/g" "$f"
 
}
 
 
 
for f in $files; do
 
sed -i 's/\.env:/\./g' "$f";
 
 
 
sed -i "s/nodeupdate(/minetest\.check_for_falling(/g" "$f"
 
 
 
# l_object.cpp
 
ref_call "getacceleration" "get_acceleration"
 
ref_call "setacceleration" "set_acceleration"
 
 
 
ref_call "getpos" "get_pos"
 
ref_call "setpos" "set_pos"
 
 
 
ref_call "getvelocity" "get_velocity"
 
ref_call "setvelocity" "set_velocity"
 
 
 
ref_call "getyaw" "get_yaw"
 
ref_call "setyaw" "set_yaw"
 
 
 
ref_call "moveto" "move_to"
 
 
 
# l_noise.cpp
 
ref_call "get2dMap" "get_2d_map"
 
ref_call "get3dMap" "get_3d_map"
 
 
 
ref_call "get2dMap_flat" "get_2d_map_flat"
 
ref_call "get3dMap_flat" "get_3d_map_flat"
 
 
 
ref_call "calc2dMap" "calc_2d_map"
 
ref_call "calc3dMap" "calc_3d_map"
 
 
 
ref_call "get2d" "get_2d"
 
ref_call "get3d" "get_3d"
 
ref_call "getMapSlice" "get_map_slice"
 
 
 
# l_settings.cpp
 
sed -i 's/\.setting_get(/\.settings:get(/g' "$f";
 
sed -i 's/\.setting_set(/\.settings:set(/g' "$f";
 
 
 
sed -i 's/\.setting_getbool/\.settings:get_bool/g' "$f";
 
sed -i 's/\.setting_setbool/\.settings:set_bool/g' "$f";
 
 
 
sed -i 's/\.setting_save/\.settings:write/g' "$f";
 
done
 
</pre>
 

Latest revision as of 10:49, 25 October 2022