Make sens to say Node instead of node. Didnt thought of that 🙂
so the main_interface is declared like so :
#onready var main_interface = get_tree().root.get_node("GameServer")
onready var main_interface = get_node("/root/GameServer")
both way leads to the same results
this is the entire function that crashes if you see where i made a mess. It all happend after i added the message to the returned variables but i dont see why. The message is built from a concatenation, but it prints correctly. I tried to pass a string instead of the message var but same error happens.
func updateSheet(nftId,nftData,typeUpdate,playerId,role):
# check that nft exists :
if not nfts.keys().has(nftId) :
print("trying to update non existant nft : ",nftId)
main_interface.ReturnUpdatedCharacter(playerId, {}, "", "Nft not found", "That nft wasn't found in the server database, please contact an admin")
else:
if typeUpdate == "stat":
#check that the modified stats are legal
var currentSheet = nfts[nftId]
var currentTotalPoints = currentSheet.statPoints
for stat in currentSheet.stats:
currentTotalPoints+=currentSheet.stats[stat]
var checkNewTotalPoints = nftData.statPoints
for stat in nftData.stats:
checkNewTotalPoints+=nftData.stats[stat]
if not checkNewTotalPoints == currentTotalPoints:
print("Illegal stat points : ",checkNewTotalPoints," - ",currentTotalPoints, " for nft : ",nftId)
main_interface.ReturnUpdatedCharacter(playerId, {}, "", "Illegal stat points", "Something seems to be wrong with your total points spent, please contact an admin")
else:
nfts[nftId].stats = nftData.stats
nfts[nftId].statPoints = nftData.statPoints
saveNftData()
refreshPlayerTeamSheets(playerId, role, nfts[nftId])
var message = role + " stats updated correctly."
print("message is : ",message)
main_interface.ReturnUpdatedCharacter(playerId, nfts[nftId], role, "success", message)
elif typeUpdate == "lvlup":
var expOverload = nftData.exp[0]-nftData.exp[1]
if expOverload < 0:
expOverload=0
nfts[nftId].lvl +=1
var expToNextLevel = int((int(nftData.Lvl)*1.15)*10000)
nfts[nftId].statPoints +=3
nfts[nftId].exp = [expOverload,expToNextLevel]
saveNftData()
refreshPlayerTeamSheets(playerId, role, nfts[nftId])
var message = "Your " + role + " has gained a level"
main_interface.ReturnUpdatedCharacter(playerId, nfts[nftId], role, "success", message)
elif typeUpdate == "custom":
nfts[nftId].custom = nftData.custom
saveNftData()
refreshPlayerTeamSheets(playerId, role, nfts[nftId])
var message = role + " appearence updated correctly."
print("message is : ",message)
main_interface.ReturnUpdatedCharacter(playerId, nfts[nftId], role, "success", message)
All my client-server communication follow that same model and all works fine except this one. (and it was working fine until I added the message)
this is the function called on the main interface :
func ReturnUpdatedCharacter(player_id, characterSheet, role, code, message):
print("boubibop : ",message)
rpc_id(player_id,"ReturnUpdatedCharacter",characterSheet, role, code, message)
And the function receiving on client side :
remote func ReturnUpdatedCharacter(characterSheet, role, code ,message):
print(code," : ",message," : ",role," : ",characterSheet)
if code == "success":
PlayerDatabase.teamSheets[role] = characterSheet
if globalFunc.loading == true:
globalFunc.loading = false
globalFunc.setMessageScreenContent({
"title":code,
"message":message
})