garrys-mod

Getting one value from a table and assigning it to another with no repeats

♀尐吖头ヾ 提交于 2019-12-12 21:09:49
问题 Specifically, this is for Garry's Mod, however I don't think that matters too much in this problem. What I want to do is get one player, and set their value to another random player (so every player has a random 'target'). I want to do this with no repeats, and so that a player is not assigned to their self. To better illustrate: The only difference to that picture is that I want each player to be assigned to another random player, so more like player1 => player 5, player 3 => player 2, etc.

Bizzare “attempt to call a table value” in Lua

孤街醉人 提交于 2019-12-01 14:13:49
问题 The following code snippet: for weight, item in itemlist do weight_total=weight_total+weight end is causing the error "attempt to call table value" on the first line in that snippet. Why? Itemlist is a table of tables of weights and strings, like such: local itemlist = { {4,"weapon_pistol"}, {2,"weapon_357"}, ... Nothing is being called as far as I can tell; why is this error coming up? 回答1: The generic for expects 3 arguments: a callable value, some value which is repeatedly passed to it,