Im new to verse coding but decent but the code for my verse device is fine exept when i build the code an error occurs and says the 1st code of line is wrong i tried eveything even changing the name of the file deleting it not having a first line of code saying module (name) can anyone please help???
If you post the code it will help.
the error code? its vErr:S77: Unexpected “MapVoteManager” following expression(3100)
and the code im using under the Map VoteManager is
module MapVoteManager
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
MapVoteManager := class(creative_device):
@editable HUD : hud_message_device
@editable PreGameLobbyTeleport : creative_device
@editable ActivateCoralCoveChannel : string = "Activate_CoralCove"
@editable ActivatePirateLandChannel : string = "Activate_PirateLand"
@editable ActivatePoolPartyChannel : string = "Activate_PoolParty"
@editable ActivateBayParkChannel : string = "Activate_BayPark"
@editable ActivateTinyTemplesChannel : string = "Activate_TinyTemples"
@editable CountdownSeconds : int = 15
VoteCounts : map[string, int] = map{
"Coral Cove" => 0,
"Pirate Land" => 0,
"Pool Party" => 0,
"Bay Park" => 0,
"Tiny Temples" => 0
}
PlayerVoted : set[player] = set{}
public RegisterVote(p:player, option:string) : void =
if (!PlayerVoted.Contains(p)):
PlayerVoted.Add(p)
VoteCounts[option] = VoteCounts[option] + 1
HUD.Show(p, "✅ Vote for " + option + " counted!")
OnBegin<override>()<suspends> : void =
StartVotingCycle()
StartVotingCycle() : void =
ResetVotes()
HUD.ShowToAll("🗳️ Voting begins! Choose a map using the menu.")
Countdown(CountdownSeconds)
Countdown(t:int) : void =
if (t > 0):
HUD.ShowToAll("Voting ends in " + ToString(t) + " seconds...")
Sleep(1s)
Countdown(t - 1)
else:
ChooseWinner()
ChooseWinner() : void =
var maxVotes = 0
var winner = "Coral Cove"
for (option, count in VoteCounts):
if (count > maxVotes):
maxVotes = count
winner = option
HUD.ShowToAll("🏆 " + winner + " wins!")
match winner:
case "Coral Cove": device:SendToChannel(ActivateCoralCoveChannel)
case "Pirate Land": device:SendToChannel(ActivatePirateLandChannel)
case "Pool Party": device:SendToChannel(ActivatePoolPartyChannel)
case "Bay Park": device:SendToChannel(ActivateBayParkChannel)
case "Tiny Temples": device:SendToChannel(ActivateTinyTemplesChannel)
Sleep(60s) # Simulate the round
TeleportToLobby()
StartVotingCycle()
ResetVotes() : void =
VoteCounts["Coral Cove"] = 0
VoteCounts["Pirate Land"] = 0
VoteCounts["Pool Party"] = 0
VoteCounts["Bay Park"] = 0
VoteCounts["Tiny Temples"] = 0
PlayerVoted.Clear()
TeleportToLobby() : void =
for (p in GetPlayspace().GetPlayers()):
PreGameLobbyTeleport.TeleportTo(p)
HUD.Show(p, "Returning to lobby to vote again...")
I tried to ‘fix’ it but there’s just too many small things.
Where did the code come from, is it AI generated? It’s the kind of code AI can generate, has the right idea, but wrong syntax and assumptions.
This probably won’t help, but here’s my attempt to fix it … still has a lot of errors.
When I changed a line, I left the original line as a comment.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
MapVoteManager := class(creative_device):
# @editable HUD : hud_message_device
@editable HUD : hud_message_device = hud_message_device{}
# @editable PreGameLobbyTeleport : creative_device
@editable PreGameLobbyTeleport : creative_device = creative_device{}
@editable ActivateCoralCoveChannel : string = "Activate_CoralCove"
@editable ActivatePirateLandChannel : string = "Activate_PirateLand"
@editable ActivatePoolPartyChannel : string = "Activate_PoolParty"
@editable ActivateBayParkChannel : string = "Activate_BayPark"
@editable ActivateTinyTemplesChannel : string = "Activate_TinyTemples"
@editable CountdownSeconds : int = 15
VoteCounts : map[string, int] = map{
"Coral Cove" => 0,
"Pirate Land" => 0,
"Pool Party" => 0,
"Bay Park" => 0,
"Tiny Temples" => 0
}
# PlayerVoted : set[player] = set{}
# public
# RegisterVote(p:player, option:string) : void =
RegisterVote(p:player, opt:string) : void =
# if (! PlayerVoted.Contains(p)):
if ( not PlayerVoted.Contains(p)):
PlayerVoted.Add(p)
# VoteCounts[option] = VoteCounts[option] + 1
VoteCounts[opt] = VoteCounts[opt] + 1
# HUD.Show(p, "✅ Vote for " + option + " counted!")
HUD.Show(p, "✅ Vote for " + opt + " counted!")
OnBegin<override>()<suspends> : void =
StartVotingCycle()
StartVotingCycle() : void =
ResetVotes()
HUD.ShowToAll("🗳️ Voting begins! Choose a map using the menu.")
Countdown(CountdownSeconds)
Countdown(t:int) : void =
if (t > 0):
HUD.ShowToAll("Voting ends in " + ToString(t) + " seconds...")
# Sleep(1s)
Sleep(1000.0)
Countdown(t - 1)
else:
ChooseWinner()
ChooseWinner() : void =
var maxVotes = 0
var winner = "Coral Cove"
# for (option, count in VoteCounts):
for (option, count : VoteCounts):
if (count > maxVotes):
maxVotes = count
winner = option
HUD.ShowToAll("🏆 " + winner + " wins!")
# match winner:
case (winner):
"Coral Cove" => device:SendToChannel(ActivateCoralCoveChannel)
"Pirate Land" => device:SendToChannel(ActivatePirateLandChannel)
"Pool Party" => device:SendToChannel(ActivatePoolPartyChannel)
"Bay Park" => device:SendToChannel(ActivateBayParkChannel)
"Tiny Temples" => device:SendToChannel(ActivateTinyTemplesChannel)
# Sleep(60s) # Simulate the round
Sleep(60) # Simulate the round
TeleportToLobby()
StartVotingCycle()
ResetVotes() : void =
VoteCounts["Coral Cove"] = 0
VoteCounts["Pirate Land"] = 0
VoteCounts["Pool Party"] = 0
VoteCounts["Bay Park"] = 0
VoteCounts["Tiny Temples"] = 0
PlayerVoted.Clear()
# Not sure what this is trying to do .. teleport a p (player) to p (player)
# TeleportToLobby() : void =
# for (p in GetPlayspace().GetPlayers()):
# PreGameLobbyTeleport.TeleportTo(p)
# HUD.Show(p, "Returning to lobby to vote again...")
# Added
# OnBegin<override>()<suspends>:void=
# {}
Yes this piece of code was ai and a j used one other piece to save time and it worked but didn’t seem to work for verse device I willy Ty this and let you know thank you
didnt work but thank you for the time and effort to try and fix it