Hello,
Please, please, remember that I'm a beginner in Lua Scripting.
Furthermore I am testing scripting in GameGuru MAX with the guess method while I am glad to accept advices of members having a deep knowledge of GameGuru.
Therefore I would advice you to stay alert. Don't follow blindly any advice I could suggest in this thread.
I am in hell.
Today, early this morning, I decided to follow the advice (a good one) of AmenMoses. I moved all my custom behaviors in my custom folder.
I reloaded my latest project w
here my behavior (test.lua) was applied to the entity "Goblin".
Workflow :
- I executed that project in edit mode.
- I verified if the behavior "test.lua" was assigned to the entity "Goblin" and as expected it wasn't loaded (because I moved all my behaviors in my custom folder containing all my GameGuru MAX projects).
- Then I selected that behavior "test.lua" found in the "user" category ( the default selection being always "objects" when the "Behavior library" opens).
- I applied again that behavior "test.lua" to the entity "Goblin".
- But ... (and I am very, very sorry about that) ... I discovered that one of my previous behaviors "playanimtracksbis.lua" was applied to the two other entities in the scene.
- In fact, from modification to modification of my initial behavior, I saved each new version in a new .lua file with new icons, according to the definitions of the _init( ) and _main( ) in the updated script.
- To rectify that, I applied the behavior "test.lua" to those entities having a previous version of my renamed behavior.
- Then I clicked on the icon (the rocket) "test game".
- The game started.
- I pressed key "1" on the numpad of my keyboard and I got an error message.
- I opened the script "test.lua" in notepad to locate the line where an error was detected (see screen capture)
My conclusion :
- Previously, two versions of my behavior (I show again these ones herewith for a better understanding of the problem) where included in that project :
- the behavior "test.lua"
g_EntityNames = {}
g_EntityNumber = {}
function test_init_name(e, name)
g_EntityNames[ e ] = name
g_EntityNumber[ name ] = e
end
function test_main(e)
local inkey = tonumber(g_InKey)
local anims = { [1] = "a1", [2] = "a2" , [3] = "a3" , [4] = "a4" , [5] = "a5" , [6] = "a6" , [7] = "a2", [8] = "n/a" }
local anim = anims[inkey]
if inkey ~= nil then
if inkey < 7 then
local entityId = g_EntityNumber[ "Goblin" ]
SetAnimationName( entityId, anim )
PlayAnimation( entityId )
Prompt("playing clip " .. anim .." for Entity #" .. "oops" .. " " .. "oops" )
end
if inkey == 7 then
local entityId = g_EntityNumber[ "movx10m" ]
SetAnimationName( entityId, anim )
PlayAnimation( entityId )
Prompt("playing clip " .. anim .." for Entity #" .. entityId .. " " .. g_EntityNames[ entityId ] )
end
if inkey == 8 then
local entityId = g_EntityNumber[ "movx10m" ]
MoveForward(5,20000)
Prompt("moving forward for Entity #" .. entityId .. " " .. g_EntityNames[ entityId ])
end
end
end
- the behavior "playanimtracksbis.lua"
function playanimtracksbis_init(e)
inkey = 0
end
function playanimtracksbis_main(e)
inkey = tonumber(g_InKey)
local anims = { [1] = "a1", [2] = "a2" , [3] = "a3" , [4] = "a4" , [5] = "a5" , [6] = "a6" , [7] = "a2", [8] = "n/a" }
local anim = anims[inkey]
if inkey ~= nil then
if inkey < 7 then
SetAnimationName(6,anim)
PlayAnimation(6)
Prompt("playing clip " .. anim .." for Entity #6 Goblin")
end
if inkey == 7 then
SetAnimationName(1,anim)
PlayAnimation(1)
Prompt("playing clip " .. anim .." for Entity #1 movex10m" )
end
if inkey == 8 then
MoveForward(5,20000)
Prompt("moving forward Entity #5 movex10m")
end
end
end
- When the project was tested with a version of each behavior included in the scene, no errors were detected and I was convinced that the behavior "test.lua" was correct.
- When the project was tested with only one behavior, the latest one, "test.lua" in the scene, then the errors in the script were detected.
- May I conclude that GameGuru MAX is using another method to identiy the entities in a game ?
Thank for reading this comment.
And again, please accept my sincere apologies.
(anyway I will return to Earth)