Object events more consistent now
Last param is now always the object emitting the event (except for singleton's like World and Clock) Lua handler no longer adds the emitting object param (is in the event now)
Dieser Commit ist enthalten in:
Ursprung
a9aef63e4e
Commit
eb63012511
@ -342,7 +342,7 @@ class LuaDoc:
|
||||
item['return_values'] = 0 if cpp_template_type.startswith('void') else 1
|
||||
elif cpp_type == 'Event':
|
||||
item['type'] = 'event'
|
||||
item['parameters'] = [{}] * (1 if cpp_template_type == '' else len(cpp_template_type.split(',')) + 1)
|
||||
item['parameters'] = [{}] * (0 if cpp_template_type == '' else len(cpp_template_type.split(',')))
|
||||
|
||||
items.append(item)
|
||||
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
{
|
||||
"name": "train"
|
||||
},
|
||||
{
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"name": "block"
|
||||
}
|
||||
@ -17,9 +14,6 @@
|
||||
{
|
||||
"name": "train"
|
||||
},
|
||||
{
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"name": "block"
|
||||
}
|
||||
|
||||
@ -12,9 +12,6 @@
|
||||
},
|
||||
{
|
||||
"name": "multiplier"
|
||||
},
|
||||
{
|
||||
"name": "clock"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -22,9 +19,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"name": "time"
|
||||
},
|
||||
{
|
||||
"name": "clock"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -32,9 +26,6 @@
|
||||
"parameters": [
|
||||
{
|
||||
"name": "time"
|
||||
},
|
||||
{
|
||||
"name": "clock"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -24,9 +24,6 @@
|
||||
},
|
||||
{
|
||||
"name": "event"
|
||||
},
|
||||
{
|
||||
"name": "world"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ void Input::updateValue(TriState _value)
|
||||
// todo: delay in ms for 0->1 || 1->0
|
||||
value.setValueInternal(_value);
|
||||
if(value != TriState::Undefined)
|
||||
fireEvent(onValueChanged, value == TriState::True);
|
||||
fireEvent<bool, const std::shared_ptr<Input>&>(onValueChanged, value == TriState::True, shared_ptr<Input>());
|
||||
}
|
||||
|
||||
void Input::interfaceChanged()
|
||||
|
||||
@ -68,7 +68,7 @@ class Input : public IdObject
|
||||
Property<uint32_t> address;
|
||||
Property<TriState> value;
|
||||
ObjectVectorProperty<Object> consumers;
|
||||
Event<bool> onValueChanged;
|
||||
Event<bool, const std::shared_ptr<Input>&> onValueChanged;
|
||||
|
||||
Input(World& world, std::string_view _id);
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ void Output::updateValue(TriState _value)
|
||||
{
|
||||
value.setValueInternal(_value);
|
||||
if(value != TriState::Undefined)
|
||||
fireEvent(onValueChanged, value == TriState::True);
|
||||
fireEvent<bool, const std::shared_ptr<Output>&>(onValueChanged, value == TriState::True, shared_ptr<Output>());
|
||||
}
|
||||
|
||||
void Output::interfaceChanged()
|
||||
|
||||
@ -68,7 +68,7 @@ class Output final : public IdObject
|
||||
Property<TriState> value;
|
||||
ObjectVectorProperty<Object> controllers;
|
||||
Method<bool(bool)> setValue;
|
||||
Event<bool> onValueChanged;
|
||||
Event<bool, const std::shared_ptr<Output>&> onValueChanged;
|
||||
|
||||
Output(World& world, std::string_view _id);
|
||||
};
|
||||
|
||||
@ -109,15 +109,16 @@ void EventHandler::execute(const Arguments& args)
|
||||
}
|
||||
}
|
||||
|
||||
push(m_L, m_event.object().shared_from_this());
|
||||
lua_rawgeti(m_L, LUA_REGISTRYINDEX, m_userData);
|
||||
|
||||
if(int r = Sandbox::pcall(m_L, args.size() + 2, 0, 0); r != LUA_OK)
|
||||
if(Sandbox::pcall(m_L, args.size() + 1, 0, 0) != LUA_OK)
|
||||
{
|
||||
Log::log(
|
||||
Sandbox::getStateData(m_L).script().id,
|
||||
LogMessage::E9001_X_DURING_EXECUTION_OF_X_EVENT_HANDLER,
|
||||
to<std::string_view>(m_L, -1),
|
||||
m_event.object().getObjectId().append(".").append(m_event.name()));
|
||||
}
|
||||
}
|
||||
|
||||
bool EventHandler::disconnect()
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren