int csp::Contract_new( lua_State* luaState ) { lua::LuaStack stack( luaState ); lua::LuaStackValue table = stack[1]; if( !table.IsTable() ) return table.ArgError( "contract table expected." ); lua::LuaStackValue contractInstance = stack.PushTable(); for ( lua::LuaStackTableIterator it( table ); it; it.Next() ) { lua::LuaStackValue channelName = it.Key(); lua::LuaStackValue value = it.Value(); if( !channelName.IsString() ) return stack.ArgError( 1, "channel name must be a string." ); if( !value.IsTable() ) return stack.ArgError( 1, "channel name must refer to Channel table." ); channelName.PushValue(); Channel* pChannel = CORE_NEW Channel(); PushChannel( luaState, *pChannel ); stack.RawSet( contractInstance ); } return 1; }
/** * Opens a new channel alongside the root channel owned by the LightmassSwarm object * * @param ChannelName Name of the channel * @param ChannelFlags Flags (read, write, etc) for the channel * @param bPushChannel If true, this new channel will be auto-pushed onto the stack * * @return The channel that was opened, without disturbing the root channel */ int32 FLightmassSwarm::OpenChannel( const TCHAR* ChannelName, int32 ChannelFlags, bool bPushChannel ) { int32 NewChannel = API.OpenChannel( ChannelName, ( NSwarm::TChannelFlags )ChannelFlags ); if ((NewChannel == NSwarm::SWARM_ERROR_CONNECTION_NOT_FOUND) || (NewChannel == NSwarm::SWARM_ERROR_CONNECTION_DISCONNECTED)) { // The connection has dropped, exit with a special code exit(SwarmConnectionDroppedExitCode); } if (bPushChannel) { PushChannel(NewChannel); } return NewChannel; }
void SoniEngine::UpdateBlocks() { switch (mode) { case 0: { std::cout << "Updating for mode 0...\n"; PushChannel(lineData.size()); UpdateSines(); UpdateAmpers(); UpdatePanners(); UpdateChannelConnections(); std::cout << "Updated.\nNum Sines: " << numSines << "\nNum Ampers: " << numAmpers << "\n"; std::cout << "Num Panners: " << numPanners << "\nNum Rows: " << numRows << "\nNum Cols: " << numCols << "\n"; break; } case 1: { std::cout << "Updating for mode 1...\n"; PushRowsCols(control->GetSelectionArea("x2") - control->GetSelectionArea("x1") + 1, control->GetSelectionArea("y2") - control->GetSelectionArea("y1") + 1); UpdateSines(); UpdateTwoDAmpers(); UpdatePanners(); UpdateMatrixConnections(); std::cout << "Updated.\nNum Sines: " << numSines << "\nNum Ampers: " << numAmpers << "\n"; std::cout << "Num Panners: " << numPanners << "\nNum Rows: " << numRows << "\nNum Cols: " << numCols << "\n"; break; } default: { std::cout << "CRITICAL ERROR: Mode is out of bounds.\n"; break; } } }