Hi,
I am having a little trouble when exporting Structs and functions across several julia files.
Here is an example
# --- agent_type.jl ---
module Agent_Type
using Agents: AbstractAgent
export Casualty
mutable struct Casualty <: AbstractAgent
id :: Int
pos :: Tuple{Int,Int}
trauma :: Int
rescued :: Bool
function Casualty(id,pos;trauma=2,rescued=false)
new(id,pos,trauma,rescued)
end
end
end
# --- ammend_props.jl ---
module Ammend_Props
include("agent_type.jl")
using .Agent_Type: Casualty
function ammend_cas_properties(cas::Casualty, val::Any)
cas.rescued = val
return cas
end
end
# -- main.jl ---
begin
using Pkg
Pkg.activate(joinpath(homedir(),"workspace","julia","envs","agentsenv"))
end
include("agent_type.jl")
include("ammend_props.jl")
using .Agent_Type: Casualty
using .Ammend_Props: ammend_cas_properties
cas1 = Casualty(1, (7,7), trauma = 3)
ammend_cas_properties(cas1, true)
>>>
ERROR: MethodError: no method matching ammend_cas_properties(::Casualty, ::Bool)
Closest candidates are:
ammend_cas_properties(::Main.Ammend_Props.Agent_Type.Casualty, ::Any) at ~/github/CRTT-lite/test/ammend_props.jl:5
Stacktrace:
[1] top-level scope
@ ~/github/CRTT-lite/test/test_main.jl:15
Any particular way I can avoid this by exporting Casualty
instead of Main.Ammend_Props.Agent_Type.Casualty