@Matteo99x and all,
The programming code used in game engines such as Unity (C#, JavaScript or Boo programming, depending on the year of the version you are using) or Unreal Engine (basically, it uses C++ programming).
However, GameGuru Classic Engine uses Lua script programming. Therefore, I'm sorry to say, but the examples of scripts written for Unity or Unreal Engine, shown above, will not work at all in GameGuru Classic for what you want to do.
To do what you want, it is not a very easy task for someone who is just starting with GameGuru Classic programming, especially spawning a new object in the same place, where another one disappeared.
To make any object disappear or appear is relatively easy, see the example below :
function hidemyobj_init(e)
Show(e);
end -- Do not remove it
function hidemyobj_main(e)
e_Key = g_Scancode;
-- e_Key for E key = 18; therefore:
if e_Key==18 then
Hide(e);
end
-- To show up the object again, click on Y key = 21; therefore
if e_Key==21 then
Show(e);
end
end -- Do not remove it
Now, save the script above with the name hidemyobj.lua in the GameGuru Classic scriptbank directory (folder). Run GameGuru Classic, and click on add new entity icon.
In Barrels, click on Barrel (Clean) and then on OK.
Place it somewhere in the terrain. Left-click on the barrel (clean) and then on properties. In the AI System Main field.
A small rectangle or square with three dots will appear.
Click on the small square mentioned, and look for the script above, called hidemyobj.lua.
Then, click on the Apply Changes button. After returning to the terrain editor, click on the Player Start icon and place it near the barrel.
So, click on the button with a rocket (Test Game) in the icon bar and test the Lua script above.
A final reminder: the name of a script in GameGuru Classic is always lowercase, remember that.
That's all.
Cheers,
-Northern