I’m trying to make a struct array, but the one thing that I cannot get to work is the instantiating the struct. I’ve looked at the struct documentation and I’ve just copied and pasted what they had about instantiating it but it still gives off an error (Data definitions at file scope must specify their value domain.) and (This archetype instantiation constructs a class that has the ‘transacts’ effect, which is not allowed by its context.)
below is what I have up to the struct instantiation.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/Diagnostics }
A Verse-authored creative device that can be placed in a level
@editable
Coordinates := struct {
X : float = 0.0
Y : float = 0.0
}
Position := Coordinates{X:= 1.0, Y:= 1.0}
Could you show us the full code? It’s possible that this struct affects other parts of your code in some way. Cray_Opeta’s code worked fine for me, so seeing the context might help identify an issue.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /UnrealEngine.com/Temporary/Diagnostics }
# A Verse-authored creative device that can be placed in a level
@editable
Coordinates := struct {
X : float = 0.0
Y : float = 0.0
}
PickMap := class(creative_device):
Position : Coordinates = Coordinates {
X:=1.0,
Y:=3.0
}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Game Started")
Well my plan was to have a struct of teleporter device array (for random tp locations) and have a variable array of that struct to make it easier to create new levels/maps
Coordinates := struct {
X : float = 0.0
Y : float = 0.0
}
PickMap := class(creative_device):
var Positions : []Coordinates = array{
Coordinates { X:=1.0, Y:=3.0 }
}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Game Started")
AddPosition(coordinates: Coordinates)<decides> : void =
set Positions = Positions + array{coordinates}
Yup which is why I had the @editable in the code from before but it gave off that build error about the unhandled attribute type. Any ideas?
Levels := struct {
@editable
Teleporters : []teleporter_device = array{teleporter_device{}}
}
PickMap := class(creative_device):
Level : []Levels = array{Levels {
}}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Game Started")
Putting @editable above ‘Level’ gives an error (The editable attribute is not supported for classes that aren’t concrete.)
and having it inside the struct doesn’t seem to be doing anything
It looks like there is a bug in Verse when referencing creative devices inside structs. This is being worked on and will be fixed in an upcoming release.
I was having a similar problem where I couldn’t assign the device to a device property in an array of structs, I got this warning “Illegal TEXT reference to a private object in external package”. I changed the struct to be a class and it worked fine