Stormworks: Build and Rescue

Stormworks: Build and Rescue

Zizo Natural Disaster Announcements [+ Radio]
Zizo  [开发者] 2022 年 2 月 10 日 上午 6:04
Script
g_savedata = { disasters = {}, notify = property.checkbox("Notify", true), draw_map = property.checkbox("Draw on map", true), radio = property.checkbox("Radio broadcasting", true), radio_frequency = property.slider("Radio broadcasting channel", 5001, 9950, 1, 4566) } local timer = 0 local addon_index = 0 local location_index = 0 local component_id = 0 function onCreate(is_world_create) addon_index = server.getAddonIndex() location_index = server.getLocationIndex(addon_index, "radio_broadcaster") local location_data = server.getLocationData(addon_index, location_index) local component_data = server.getLocationComponentData(addon_index, location_index, location_data.component_count) component_id = component_data.id end function onTick(delta_worldtime) if timer <= 0 then timer = 60 * 10 for id, disaster in pairs(g_savedata.disasters) do if disaster.time <= 0 then if disaster.marker_ui_id then server.removeMapObject(-1, disaster.marker_ui_id) end if disaster.vehicle_id then server.despawnVehicle(disaster.vehicle_id, true) end g_savedata.disasters[id] = nil else if not disaster.marker_ui_id then disaster.marker_ui_id = server.getMapID() if g_savedata.notify then server.notify(-1, "Warning: Extreme weather", disaster.desc,1) end if g_savedata.draw_map then server.addMapObject(-1, disaster.marker_ui_id, 0, 8, disaster.transform[13], disaster.transform[15], 0, 0, 0, 0, "Warning: Extreme weather", disaster.size, disaster.desc, 200, 100, 0, 255) end if g_savedata.radio then local broadcast_transform = disaster.transform broadcast_transform[14] = -350 local component = server.spawnAddonComponent(broadcast_transform, addon_index, location_index, component_id) disaster.vehicle_id = component.id end end disaster.time = disaster.time - timer end end else timer = timer - 1 end end function onVehicleLoad(vehicle_id) for _, disaster in pairs(g_savedata.disasters) do if vehicle_id == disaster.vehicle_id then server.setVehicleKeypad(vehicle_id, "radio_frequency", g_savedata.radio_frequency) server.setVehicleKeypad(vehicle_id, "disaster_type", disaster.type) server.setVehicleKeypad(vehicle_id, "disaster_magnitude", disaster.magnitude) break end end end function onTornado(transform) table.insert(g_savedata.disasters, { transform=transform, time=60*60*4, size=1000, magnitude=10, type=1, desc="Extreme wind has been detected on location." }) end function onTsunami(transform, magnitude) table.insert(g_savedata.disasters, { transform=transform, time=60*60*5, size=3000+3000*magnitude, magnitude=magnitude*12, type=2, desc="Seismic activity has caused large scale ocean displacement, a tsunami warning has been issued. Magnitude ".. math.floor(magnitude*12*100)/100 }) end function onWhirlpool(transform, magnitude) table.insert(g_savedata.disasters, { transform=transform, time=60*60*6, size=250+250*magnitude, magnitude=magnitude*12, type=3, desc="Tectonic disruptions to the seabed are causing unpredictable water currents. Magnitude ".. math.floor(magnitude*12*100)/100 }) end function onMeteor(transform, magnitude) table.insert(g_savedata.disasters, { transform=transform, time=60*60*1, size=1000, magnitude=magnitude*10, type=4, desc="Nearby weather stations have detected an incoming impact event. Magnitude ".. math.floor(magnitude*10*100)/100 }) end function onVolcano(transform) table.insert(g_savedata.disasters, { transform=transform, time=60*60*2, size=2000, magnitude=8, type=5, desc="Seismic activity in the area has triggered a volcanic response." }) end
最后由 Zizo 编辑于; 2023 年 7 月 3 日 下午 3:06
< >
正在显示第 1 - 10 条,共 10 条留言
Seraph 2022 年 2 月 12 日 上午 12:58 
ok cool
roulxseth kaardeth 2022 年 2 月 12 日 上午 8:11 
what da f--- does that mean
Lopsided Phenomenon 2022 年 2 月 13 日 上午 1:18 
looks cool not gonna try it even!
SIMPLE MARK 2022 年 2 月 13 日 上午 11:09 
Nice implementation, could not improve much on it!
Mökki 2022 年 2 月 13 日 下午 1:38 
Clear, short and as basic as it needs to be. Couldn't do it better!
RadialVolcano27 2023 年 6 月 8 日 下午 8:44 
I'm making an addon that is pretty much this but codded it all myself (I had to use this code to help me a little with the timer part though), and I was wondering if I'm allowed to put it on the workshop when it's done?
Zizo  [开发者] 2023 年 7 月 3 日 上午 4:01 
引用自 RadialVolcano27
I'm making an addon that is pretty much this but codded it all myself (I had to use this code to help me a little with the timer part though), and I was wondering if I'm allowed to put it on the workshop when it's done?
sure, no problem
TomMaverick 2023 年 7 月 4 日 上午 9:24 
Hi!
Im getting a message in chat when I start a game with this addon.


.../2749036818/playlist
21: attempt to index a nil value (local 'component_data')

Screenshot [i.imgur.com]

Already tried to ?reload_scripts but I get the same message.


Edit:
This seems to happen only in Career and Classic Career mode.

Edit 2: Nope sry my error! The message pops up in Custom as well. But the Addon seems to work regardless.



Thanks for all the addons you make! <3
最后由 TomMaverick 编辑于; 2023 年 7 月 4 日 上午 10:02
Zizo  [开发者] 2023 年 7 月 4 日 上午 11:15 
引用自 TomMaverick
Hi!
Im getting a message in chat when I start a game with this addon.


.../2749036818/playlist
21: attempt to index a nil value (local 'component_data')

Screenshot [i.imgur.com]

Already tried to ?reload_scripts but I get the same message.


Edit:
This seems to happen only in Career and Classic Career mode.

Edit 2: Nope sry my error! The message pops up in Custom as well. But the Addon seems to work regardless.



Thanks for all the addons you make! <3
Hello TomMaverick,

thanks for reporting the issue, I am already uploading a fix, the addon worked the same weirdly enough but now it doesn't print an error.
Daquan Baton 2024 年 4 月 8 日 下午 8:12 
Everything works pretty good, up until the mod experiences an error and causes the siren in one location to play constantly.

This is the error I'm getting:
22: attempt to index a nil value (local 'location data')
< >
正在显示第 1 - 10 条,共 10 条留言
每页显示数: 1530 50