I have about the same levels and i want to copy them and change something inside colections. But when i try to copy them and switch between them defold give me an eror message: The collection /level/level.collectionc could not be loaded since it was already. Message ‘load’ sent from main:/loader#script to main:/screens#level.
The problem has nothing to do about copy-pasting collections and proxies, but in how you write your logic. You always reset save_state.level to 0 in the function (line 56), so the first elseif will be executed for every “goto_game” sent to the on_message. It looks like you intend it to be able to switch between different ones. These problems can be quickly resolved by printing the values you test on:
print(message_id)
print(save_state.level)
in the on_message function. That will show you what is actually happen and how that might differ from what you expect. Please always do that before asking in the forum. It’s a bit like googling/searching in the forum before asking questions and it saves us a lot of time. Come prepared.
Feedback: The indentation of your code in the first screenshot is not good. It’s really hard to read the code like that. Compare this piece of code that is similar to what you wrote:
local a,b,c,d
if a == b then
print("foo")
elseif a == c then
print("bar")
else if a == d then
print("boo")
else if a == d then
print("bar")
elseif b ==c then
print("goo")
end
end
end
With code formatted like this:
local a,b,c,d
if a == b then
print("foo")
elseif a == c then
print("bar")
else
if a == d then
print("boo")
else
if a == d then
print("bar")
elseif b ==c then
print("goo")
end
end
end
On the other hand, I’m not even sure if you intended to write elseif
instead of else if
?