MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / _set

Method _set

src/script/api/script_list.cpp:766–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766SQInteger ScriptList::_set(HSQUIRRELVM vm)
767{
768 if (sq_gettype(vm, 2) != OT_INTEGER) return SQ_ERROR;
769
770 SQInteger idx;
771 sq_getinteger(vm, 2, &idx);
772
773 /* Retrieve the return value */
774 SQInteger val;
775 switch (sq_gettype(vm, 3)) {
776 case OT_NULL:
777 this->RemoveItem(idx);
778 return 0;
779
780 case OT_BOOL: {
781 SQBool v;
782 sq_getbool(vm, 3, &v);
783 val = v ? 1 : 0;
784 break;
785 }
786
787 case OT_INTEGER:
788 sq_getinteger(vm, 3, &val);
789 break;
790
791 default:
792 return sq_throwerror(vm, "you can only assign integers to this list");
793 }
794
795 if (!this->HasItem(idx)) {
796 this->AddItem(idx, val);
797 return 0;
798 }
799
800 this->SetValue(idx, val);
801 return 0;
802}
803
804SQInteger ScriptList::_nexti(HSQUIRRELVM vm)
805{

Callers

nothing calls this directly

Calls 8

RemoveItemMethod · 0.95
HasItemMethod · 0.95
AddItemMethod · 0.95
SetValueMethod · 0.95
sq_gettypeFunction · 0.85
sq_getintegerFunction · 0.85
sq_getboolFunction · 0.85
sq_throwerrorFunction · 0.85

Tested by

no test coverage detected