Loading...
  OR  Zero-K Name:    Password:   

Post edit history

To all you cheaters: Here's some help

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
6/11/2016 4:38:23 PMUSrankShaman before revert after revert
6/11/2016 2:01:49 PMUSrankShaman before revert after revert
Before After
1 [quote]I know how you feel. That's why I am working on developing a widget that will turn input such as[/quote] 1 [quote]I know how you feel. That's why I am working on developing a widget that will turn input such as[/quote]
2 \n 2 \n
3 \n 3 \n
4 [url=http://lua-users.org/wiki/StringLibraryTutorial]This will probably help you a lot.[/url] You could do: 4 [url=http://lua-users.org/wiki/StringLibraryTutorial]This will probably help you a lot.[/url] You could do:
5 \n 5 \n
6 [quote] 6 [quote]
7 local units = {} 7 local units = {}
8 for id,data in pairs(UnitDefs) do 8 for id,data in pairs(UnitDefs) do
9 units[string.lower(data.humanname)] = data.name 9 units[string.lower(data.humanname)] = data.name
10 end -- Reverse lookup 10 end -- Reverse lookup
11 \n 11 \n
12 function widget:GotChatMsg(msg, player) 12 function widget:GotChatMsg(msg, player)
13 if string.find(string.lower(msg),"givee") ~= nil and player == Spring.GetMyPlayerID() then -- done on purpose so we don't trigger give. 13 if string.find(string.lower(msg),"givee") ~= nil and player == Spring.GetMyPlayerID() then -- done on purpose so we don't trigger give.
14 local command = string.gmatch(msg, "%S+") -- Split string into pieces. "/givee 1 glaive 1" results in {"/givee","1","glaive","1"} 14 local command = string.gmatch(msg, "%S+") -- Split string into pieces. "/givee 1 glaive 1" results in {"/givee","1","glaive","1"}
15 local unit = "" 15 local unit = ""
16 for i=1,#command do 16 for i=1,#command do
17 if string.find(command[i],"give") == nil and string.len(command[i]) > 3 then 17 if string.find(command[i],"give") == nil and string.len(command[i]) > 3 then
18 unit = command[i] 18 unit = command[i]
19 break 19 break
20 end 20 end
21 end 21 end
22 if units[unit] == nil then 22 if units[unit] == nil then
23 Spring.Echo("game_message:Invalid unit! Check spelling!") 23 Spring.Echo("game_message:Invalid unit! Check spelling!")
24 end 24 end
25 local str 25 local str
26 --reform command-- 26 --reform command--
27 for i=1,#command do 27 for i=1,#command do
28 if string.find(command[i],"givee") == nil then 28 if string.find(command[i],"givee") == nil then
29 str = str .. command[i] 29 str = str .. command[i]
30 else 30 else
31 str = str .. "give" 31 str = str .. "give"
32 end 32 end
33 Spring.SendCommands(str) 33 Spring.SendCommands(str)
34 str,command = nil 34 str,command = nil
35 end 35 end
36 [/quote] 36 [/quote]
37 \n
38 \n
39 Other useful links:
40 [url=https://springrts.com/wiki/Lua:Callins]Spring Callins ("events") and what they do[/url]
41 [url=https://springrts.com/wiki/Lua_Scripting]Spring LUA functions[/url]